From: Joe W. <joe...@us...> - 2002-10-06 23:11:43
|
Update of /cvsroot/mockobjects/nmock/test/NMock/Dynamic In directory usw-pr-cvs1:/tmp/cvs-serv5221/test/NMock/Dynamic Modified Files: ClassGeneratorTest.cs Log Message: Bytecode now emitted for property setters/getters Index: ClassGeneratorTest.cs =================================================================== RCS file: /cvsroot/mockobjects/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- ClassGeneratorTest.cs 6 Oct 2002 20:49:09 -0000 1.1.1.1 +++ ClassGeneratorTest.cs 6 Oct 2002 23:11:39 -0000 1.2 @@ -22,6 +22,9 @@ bool boolReturn(); double doubleReturn(); IThingy AThingy(); + string ReadProperty { get; } + string WriteProperty { set; } + string AProperty { get; set; } } [TestFixture] @@ -161,6 +164,40 @@ IList l = new ArrayList(); mock.Expect("WithOtherArgs", new IsEqual(6), new IsEqual(true), new IsNull(), new IsEqual(l)); thingy.WithOtherArgs(6, true, null, l); + mock.Verify(); + } + + [Test] + public void CallReadOnlyProperty() + { + mock.ExpectAndReturn("ReadProperty", "hello"); + mock.ExpectAndReturn("ReadProperty", "world"); + Assertion.AssertEquals("hello", thingy.ReadProperty); + Assertion.AssertEquals("world", thingy.ReadProperty); + mock.Verify(); + } + + [Test] + public void WriteOnlyPropertyExpectations() + { + mock.Expect("WriteProperty", "hello"); + mock.Expect("WriteProperty", "world"); + thingy.WriteProperty = "hello"; + thingy.WriteProperty = "world"; + mock.Verify(); + } + + [Test] + public void ReadAndWriteProperty() + { + mock.Expect("AProperty", "hello"); + mock.Expect("AProperty", "world"); + mock.ExpectAndReturn("AProperty", "good"); + mock.ExpectAndReturn("AProperty", "bye"); + thingy.AProperty = "hello"; + thingy.AProperty = "world"; + Assertion.AssertEquals("good", thingy.AProperty); + Assertion.AssertEquals("bye", thingy.AProperty); mock.Verify(); } |