public void ItShouldPointToTheLocationOfTheAssertion() { var rule = new AvoidAssertBooleanRule(); var violations = rule.Apply(_violatingAction.AsTestCase(new NUnitTestFramework())); var location = violations.First().Location; Assert.AreEqual(19, location.StartLine); }
public void ItShouldProvideAMessage() { var rule = new AvoidAssertBooleanRule(); var violations = rule.Apply(_violatingAction.AsTestCase(new NUnitTestFramework())); var message = violations.First().Message; Assert.AreEqual("Assert.False performs a boolean test on a composite boolean value", message); }
public void ItShouldNotComplainAboutAssertingASingleBooleanValue() { Action a = () => { var actual = Environment.Is64BitOperatingSystem; Assert.True(actual); }; var rule = new AvoidAssertBooleanRule(); var violations = rule.Apply(a.AsTestCase(new NUnitTestFramework())); Assert.AreEqual(0, violations.Count()); }
public void ItShouldComplainAboutAssertingABooleanValueResultingFromAEqualsComparison() { Action a = () => { var x = 5; var y = 6; Assert.False(x.Equals(y)); }; var rule = new AvoidAssertBooleanRule(); var violations = rule.Apply(a.AsTestCase(new NUnitTestFramework())); Assert.AreEqual(1, violations.Count()); }
public void ItShouldHaveAToStringDescription() { var rule = new AvoidAssertBooleanRule(); Assert.AreEqual("a test case should not do a boolean assertion of a composite boolean value", rule.ToString()); }
public void ItShouldComplainAboutAssertingABooleanValueResultingFromAnOperatorComparison() { var rule = new AvoidAssertBooleanRule(); var violations = rule.Apply(_violatingAction.AsTestCase(new NUnitTestFramework())); Assert.AreEqual(1, violations.Count()); }