Hi, I am testing a method whereby a value is set in the method. Initially I set the return value using JustMock. This is SharePoint by the way.
01.
// arrange
02.
SPItemEventProperties properties = Mock.Create<SPItemEventProperties>(Behavior.Strict);
03.
Mock.Arrange(() => properties.BeforeProperties[
"Title"
]).Returns(
"Old Title"
);
04.
Mock.Arrange(() => properties.AfterProperties[
"Title"
]).Returns(
"New Title"
);
05.
06.
// act
07.
Person p =
new
Person();
08.
p.DoSomething(properties);
// -> properties.AfterProperties["Title"] = "abc";
09.
10.
// assert
11.
Assert.AreEqual(
"abc"
, properties.AfterProperties[
"Title"
].ToString());
// fails here since AfterProperties is still "New Title"
I realize that the .Return is causing the same value to be returned. How can I check that the correct value is being set inside the method / can I get the value which has been set in the method back in the assert.arequal?
Thanks,
Gary.