1

I'm new to AutoFixture and quickly testing out its features but I'm running into a bit of a snag. Below is my test:

// Arrange
Fixture.Register(() => Fixture.CreateMany<SyncItemChange>(10));
var syncFolderItemsResult = Fixture.CreateAnonymous<SyncFolderItemsResult>();
ExchangeWebServiceMock
    .Setup(x => x.Sync())
    .Returns(() => syncFolderItemsResult);

// Act
Listener.Begin();

// Assert
var expectedItemIdsToBind = syncFolderItemsResult
    .ItemChanges
    .Select(x => x.ItemId);
ExchangeWebServiceMock.Verify(x => x.BindToItems(expectedItemIdsToBind), Times.Once());

Nothing fancy. The issue I'm running into is that when I first create an anonymous instance of SyncFolderItemsResult, the SyncItemsChanges aren't the same from the time I create it to the time I assert that I'm binding the proper ItemId's. Thus, making the test fail.

Why am I generating 2 different lists?

Nosila
  • 540
  • 7
  • 20
  • 4
    This answer should help: http://stackoverflow.com/questions/6181865/autofixture-ienumerablet-behavior-with-creatmany/6183359#6183359 – Nikos Baxevanis Apr 17 '12 at 13:20
  • That fixed the issue, thank you. If you want to add that as your answer I will gladly accept it. :D – Nosila Apr 17 '12 at 13:55

0 Answers0