public async Task CreateBankTransaction_Run_Success() { // arrange var mock = new Mock <ILogger>(); var createBankTransactionFunction = new CreateBankTransaction(_mediatorService); var createBankTransactionRequest = new HttpRequestMessage { Content = new StringContent(JsonConvert.SerializeObject(new CreateBankTransactionCommand { Amount = 3, Memo = "Groceries", CategoryId = 1, AccountId = 1 }), Encoding.UTF8, "application/json") }; // act var result = await createBankTransactionFunction.Run(createBankTransactionRequest, mock.Object, CancellationToken.None); // assert Assert.Multiple(() => { Assert.IsInstanceOf <OkObjectResult>(result); Assert.AreEqual(1, ((OkObjectResult)result).Value); }); }
public async Task CreateBankTransaction_Run_FailValidations() { // arrange var mock = new Mock <ILogger>(); var createBankTransactionFunction = new CreateBankTransaction(_mediatorService); var createBankTransactionRequest = new HttpRequestMessage { Content = new StringContent(JsonConvert.SerializeObject(new CreateBankTransactionCommand { Amount = 0 }), Encoding.UTF8, "application/json") }; // act var result = await createBankTransactionFunction.Run(createBankTransactionRequest, mock.Object, CancellationToken.None); // assert Assert.Multiple(() => { Assert.IsInstanceOf <BadRequestObjectResult>(result); }); }