In my test I am using both MockingContainer and Mock to do Automocking and create concrete mocks respectively.
At the end of my test I want to ensure all of the functions I setup via Arrange for both the MockingContainer and mocked classes were ran.
Do I need to call .AssertAll() for each mocked object and the MockingContainer or can I simply call Mock.AssertAll() to make sure all Arranged functions were executed? See example below for both approaches.
// Establish mocks
var mockedControllerContainer = new MockingContainer<SomeController>();
var mockedClass = Mock.Create<SomeClass>();
// Establish test variables
IEnumerable<SomeDomainModel> records = new List<SomeDomainModel>();
// Arrange Mocks
mockedControllerContainer
.Arrange<Repository>(repo => repo.FetchRecordsWithName("name"))
.Returns(records);
mockedClass
.Arrange(c => c.SomeFunction())
.Returns(null);
// Assert
mockedControllerContainer.AssertAll();
mockedClass.AssertAll();
// Or can I use the example below to cover all cases?
Mock.AssertAll();
Which approach is best practice to ensure each function was called? This example only had one concrete class but other tests can have many so if I can avoid having to use .AssertAll() for each of them individutally that would be ideal.
The API documentation for Mock.AssertAll() states "Asserts all expected setups in the current context". How is this context defined?
Thank you!