public void ParseMethod_NotValidVariableString_FormatException(string variableString) { Should.Throw <FormatException>(() => { var parseResult = SummandParser.Parse(variableString); }); }
public void ParseMethod_WhiteSpaceString_ThrowNullArgumentException() { Should.Throw <ArgumentNullException>(() => { var parseResult = SummandParser.Parse(" "); }); }
public void Parse_ValidParameters_CorrectParsing(string input, float expectedCoefficient, int expectedMaxExponent, string expectedSummandID) { var summand = SummandParser.Parse(input); Assert.AreEqual(expectedCoefficient, summand.Coefficient); Assert.AreEqual(expectedMaxExponent, summand.MaxExponent); Assert.AreEqual(expectedSummandID, summand.SummandID); }
public void ParseMethod_ValidVariableString_ReturnVariables(string variableString, float multiplier, int countVariables, IList <Variable> expectedVariables) { Summand parseResult = null; Should.NotThrow(() => { parseResult = SummandParser.Parse(variableString); }); parseResult.ShouldNotBeNull(); parseResult.Multiplier.ShouldBe(multiplier); parseResult.Variables.Count().ShouldBe(countVariables); var sortedActualResult = parseResult.Variables.OrderBy(x => x.Name).ThenBy(x => x.Power).ToArray(); var sortedExpectedResult = expectedVariables.OrderBy(x => x.Name).ThenBy(x => x.Power).ToArray(); for (int i = 0; i < sortedActualResult.Length; i++) { var expectedValue = sortedExpectedResult[i]; sortedActualResult[i].Name.ShouldBe(expectedValue.Name); sortedActualResult[i].Power.ShouldBe(expectedValue.Power); } }