unit tests passing

This commit is contained in:
TomPallister
2020-02-18 20:45:28 +00:00
parent b8922cef5f
commit e969e9ff0b
4 changed files with 49 additions and 11 deletions

View File

@ -1,12 +1,16 @@
namespace Ocelot.UnitTests.Configuration
{
using System;
using Ocelot.Configuration.Creator;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class VersionCreatorTests
{
private readonly VersionCreator _creator;
private string _input;
private Version _result;
public VersionCreatorTests()
{
@ -16,19 +20,35 @@
[Fact]
public void should_create_version_based_on_input()
{
var input = "2.0";
var result = _creator.Create(input);
result.Major.ShouldBe(2);
result.Minor.ShouldBe(0);
this.Given(_ => GivenTheInput("2.0"))
.When(_ => WhenICreate())
.Then(_ => ThenTheResultIs(2, 0))
.BDDfy();
}
[Fact]
public void should_default_to_version_one_point_one()
{
var input = "";
var result = _creator.Create(input);
result.Major.ShouldBe(1);
result.Minor.ShouldBe(1);
this.Given(_ => GivenTheInput(""))
.When(_ => WhenICreate())
.Then(_ => ThenTheResultIs(1, 1))
.BDDfy();
}
private void GivenTheInput(string input)
{
_input = input;
}
private void WhenICreate()
{
_result = _creator.Create(_input);
}
private void ThenTheResultIs(int major, int minor)
{
_result.Major.ShouldBe(major);
_result.Minor.ShouldBe(minor);
}
}
}