public void PositiveTrickyAutoProp3() { var tricky = new TrickyAutoPropInvariants <Valid>(new Valid(true), 0, false); try { tricky.LeaveObjectInconsistent(); } catch (ApplicationException) { } // now we can violate invariant further without being punished tricky.Age = 5; }
public void NegativeTrickyAutoProp2() { try { var tricky = new TrickyAutoPropInvariants <Valid>(new Valid(true), 0, false); tricky.Age = 5; throw new Exception(); } catch (TestRewriterMethods.PreconditionException i) { Assert.AreEqual("Flag ? Age > 0 : Age == 0 && Value.IsValid", i.Condition); } }
public void NegativeTrickyAutoProp4() { try { var tricky = new TrickyAutoPropInvariants <Valid>(new Valid(true), 0, false); try { tricky.LeaveObjectConsistentViaAdvertisedException(); } catch (ApplicationException) { } tricky.Age = 5; // should fail precondition throw new Exception(); } catch (TestRewriterMethods.PreconditionException i) { Assert.AreEqual("Flag ? Age > 0 : Age == 0 && Value.IsValid", i.Condition); } }
public void PositiveTrickyAutoProp1() { var tricky = new TrickyAutoPropInvariants <Valid>(new Valid(true), 0, false); tricky.Change(true, 5); }