public async Task Update_ReturnsOkResult() { // Arrange var walletId = 1; var wallet = new WalletDTO() { Id = walletId }; var mockWallet = new Mock <IWalletService>(); var mockPerson = new Mock <IPersonService>(); mockWallet.Setup(p => p.UpdateAsync(walletId, It.IsAny <WalletDTO>())); WalletsController controller = new WalletsController(mockWallet.Object, mockPerson.Object); // Act var result = await controller.Update(walletId, wallet) as OkResult; // Assert Assert.IsNotNull(result); Assert.AreEqual(result.StatusCode, 200); }
public async Task UpdateVerifyOnce() { //Arrange WalletDTO walletDTO = new WalletDTO { Id = 45, Description = "Wallet", Balance = 500 }; var mockWallet = new Mock <IWalletService>(); var mockPerson = new Mock <IPersonService>(); WalletsController controller = new WalletsController(mockWallet.Object, mockPerson.Object); mockWallet.Setup(x => x.UpdateAsync((int)walletDTO.Id, walletDTO)); //Act await controller.Update((int)walletDTO.Id, walletDTO); //Assert mockWallet.Verify(x => x.UpdateAsync((int)walletDTO.Id, walletDTO)); }