Hi,
First welcome to the world of mocking.
Just to make things clear, mocking is used to
isolate the code you want to test. This is done by setting up the behavior of classes that interact with the tested classes.
Basiclly it means that you mock
Methods not fields.
In your case you can mock the DestinationGuid property as follows:
[Test]
public void MyTest()
{
// Start
MockManager.Init();
// mock next instance of Destination
Mock mockControl = MockManager.Mock(typeof(Destination));
// expect DestinationGuid to be called once and return dummyGuid
mockControl.ExpectGet("DestinationGuid",dummyGuid);
// This is just a test to show how it works,
// you normally would put your real test here
// this instance of Destination will be mocked
Destination d = new Destination();
// the Property will return our dummy result
Assert.AreEqual(dummyGuid,d.DestinationGuid);
// Check that all expected calls where made
MockManager.Verify();
}
:arrow: Note: A better practice is to put
MockManager.Init() in the SetUp method and
MockManager.Verify() in the TearDown.
This will ensure that your types will always be mocked and that they will be verified even if the test threw an excpetion, thus not leaving any mocked classes alive between tests.