public void UpdateResultWithExpectedValue(string[] inputValues, double[] result) { var rawInput = inputValues.ToMultilineText(); var expectedValue = result.Select(value => value.ToString()).ToMultilineText(); FakeFormatter.ToCollection(rawInput).Returns(inputValues); FakeFormatter.ToText(null).ReturnsForAnyArgs(expectedValue); var converter = ConfigureConverterFor(inputValues, result); Viewmodel.ConvertWith(converter, rawInput); Viewmodel.Result.Should().Be(expectedValue); }
public void PassConvertedValuesToFormatterAsCollectionOfInvariantCultureString(string[] inputValues, double[] result) { var expectedOutputValues = result.Select(value => value.ToString(CultureInfo.InvariantCulture)); IEnumerable<string> actualOutputValues = null; var inputValue = inputValues.ToMultilineText(); FakeFormatter.ToCollection(inputValue).ReturnsForAnyArgs(inputValues); FakeFormatter.ToText(Arg.Do<IEnumerable<string>>(values => actualOutputValues = values)).ReturnsForAnyArgs(string.Empty); var converter = ConfigureConverterFor(inputValues, result); Viewmodel.ConvertWith(converter, inputValue); actualOutputValues.ShouldBeEquivalentTo(expectedOutputValues); }
public void PassExpectedInputValuesToConverter(string[] inputValues, double[] expectedInput) { var dummyResult = 0.1; var actualInput = new List<double>(); var inputValue = inputValues.ToMultilineText(); FakeFormatter.ToCollection(inputValue).ReturnsForAnyArgs(inputValues); FakeFormatter.ToText(null).ReturnsForAnyArgs(config => config.Arg<IEnumerable<string>>().ToList().ToString()); var converter = Substitute.For<IUnitConverter>(); converter.Convert(Arg.Do<double>(value => actualInput.Add(value))).ReturnsForAnyArgs(dummyResult); Viewmodel.ConvertWith(converter, inputValue); actualInput.ShouldBeEquivalentTo(expectedInput); }
public void PassNaNValuesToFormatterWhenWrongFormattedValuesGiven() { var expectedOutputValues = new[] { "NaN", "NaN" }; IEnumerable<string> actualOutputValues = null; var inputValues = new[] { "2,9", "1.O8" }; var inputValue = inputValues.ToMultilineText(); var parsedValues = new[] { double.NaN, double.NaN }; var result = new[] { double.NaN, double.NaN }; FakeFormatter.ToCollection(inputValue).ReturnsForAnyArgs(inputValues); FakeFormatter.ToText(Arg.Do<IEnumerable<string>>(values => actualOutputValues = values)).ReturnsForAnyArgs(string.Empty); var converter = ConfigureConverterFor(parsedValues, result); Viewmodel.ConvertWith(converter, inputValue); actualOutputValues.ShouldBeEquivalentTo(expectedOutputValues); }