public void PredefinedUnit_ShouldParseExactToExpectedUnit(ExactlyParsableUnitTestData testData) { // arrange var parser = new WeightUnitParser(); // act var actualUnit = parser.ParseExact(testData.ParseValue, testData.ParseFormat, null); // assert actualUnit.Should().Be(testData.ExpectedUnit); }
public void UnknownFormat_ShouldThrow() { // arrange var parser = new WeightUnitParser(); // act Action parseExact = () => parser.ParseExact(WeightUnit.Kilogram.Name, Fixture.Create <string>(), null); // assert parseExact.Should().Throw <FormatException>(); }
public void PredefinedUnit_ShouldParseToExpectedUnit(ParseUnitTestData testData) { // arrange var parser = new WeightUnitParser(); // act var actualUnit = parser.Parse(testData.ParseValue); // assert actualUnit.Should().Be(testData.ExpectedUnit); }
public void UnknownUnit_ShouldThrow() { // arrange var parser = new WeightUnitParser(); // act Action parse = () => parser.Parse(Fixture.Create <string>()); // assert parse.Should().Throw <FormatException>(); }
public void PredefinedUnit_ShouldParseToExpectedUnitAndReturnTrue(TryParsWeightUnitTestData testData) { // arrange var parser = new WeightUnitParser(); // act bool result = parser.TryParse(testData.ParseValue, out var actualUnit); // assert actualUnit.Should().Be(testData.ExpectedUnit); result.Should().BeTrue(); }
public void UnknownUnit_ShouldSetUnitToDefaultAndReturnFalse() { // arrange var parser = new WeightUnitParser(); // act bool result = parser.TryParse(Fixture.Create <string>(), out var actualUnit); // assert actualUnit.Should().Be(default(WeightUnit)); result.Should().BeFalse(); }