public async Task HandleAsync_WithValidData_ShouldFinishShoppingList() { // Arrange var fixture = commonFixture.GetNewFixture(); TransactionGeneratorMock transactionGeneratorMock = new TransactionGeneratorMock(fixture); ShoppingListRepositoryMock shoppingListRepositoryMock = new ShoppingListRepositoryMock(fixture); Mock <ITransaction> transactionMock = new Mock <ITransaction>(); ShoppingListMock listMock = shoppingListMockFixture.Create(); ShoppingListMock remainingListMock = shoppingListMockFixture.Create(); var command = fixture.Create <FinishShoppingListCommand>(); var handler = fixture.Create <FinishShoppingListCommandHandler>(); listMock.SetupFinish(command.CompletionDate, remainingListMock.Object); shoppingListRepositoryMock.SetupFindByAsync(command.ShoppingListId, listMock.Object); transactionGeneratorMock.SetupGenerateAsync(transactionMock.Object); // Act bool result = await handler.HandleAsync(command, default); // Assert using (new AssertionScope()) { result.Should().BeTrue(); listMock.VerifyFinishOnce(command.CompletionDate); transactionGeneratorMock.VerifyGenerateAsyncOnce(); shoppingListRepositoryMock.VerifyStoreAsyncOnce(listMock.Object); shoppingListRepositoryMock.VerifyStoreAsyncOnce(remainingListMock.Object); transactionMock.Verify( i => i.CommitAsync( It.IsAny <CancellationToken>()), Times.Once); } }
public IEnumerator <object[]> GetEnumerator() { var commonFixture = new CommonFixture(); var shoppingListFixture = new ShoppingListFixture(commonFixture); var shoppingListMockFixture = new ShoppingListMockFixture(commonFixture, shoppingListFixture); yield return(new object[] { shoppingListMockFixture.Create().ToMonoList() }); yield return(new object[] { shoppingListMockFixture.CreateMany(3).ToList() }); yield return(new object[] { new List <ShoppingListMock>() }); }