This is my interface
public interface IWork
{
string GetIdentifierForItem(Information information);
}
and my class
publ
You don't need to Mock the Lazy
. It is flexible enough to work with your test. Instead, Mock the IWindowTypeInfo
[TestMethod]
public void GetIDTest()
{
var windowTypeInfoMock = new Mock();
windowTypeInfoMock.Setup(foo => foo.Name).Returns("Data");
windowTypeInfoMock.Setup(foo => foo.UniqueID).Returns("someString");
var lazyWindow =
new Lazy(windowTypeInfoMock.Object);
var WindowTypesList = new List>();
WindowTypesList.Add(lazyWindow);
var a = new A();
a.WindowTypes = WindowTypesList;
var InfoMock = new Mock();
InfoMock.Setup(foo => foo.TargetName).Returns("Data");
string expected = "someString";
string actual;
actual = a.GetIdentifierForItem(InfoMock.Object);
Assert.AreEqual(expected, actual);
}
Your test passes on my machine with only small modifications, you do not need to use a composition container for this test.