public async void GetPaymentById_WhenUserIdDoesntEqualPaymentsUserId_ReturnsForbidResult() { var userId = Guid.NewGuid().ToString(); var paymentUserId = Guid.NewGuid().ToString(); _userManagerMock.Setup(x => x.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(new User { Id = userId }); _paymentsServiceMock.Setup(x => x.GetPaymentByIdAsync(It.IsAny <string>())).ReturnsAsync(new PaymentDetails { UserId = paymentUserId }); var result = await _paymentsController.GetPaymentById(It.IsAny <string>()); var actionResult = Assert.IsType <ActionResult <PaymentDetailsDto> >(result); Assert.IsType <ForbidResult>(actionResult.Result); }
public void CreatePayment() { var context = serviceProvider.GetRequiredService <DataContext>(); var controller = new PaymentsController(context); controller.PostPayment(payment1); var createdPayment = controller.GetPaymentById(payment1.Id).Result.Value; Assert.Equal(createdPayment, payment1); }
public void GetByIdPayment_ShouldReturnPaymentById() { var context = serviceProvider.GetRequiredService <DataContext>(); var controller = new PaymentsController(context); context.Payment.Add(payment1); var payment = controller.GetPaymentById(1).Result.Value; Assert.Equal(payment, payment1); }
public void DeletePayment() { var context = serviceProvider.GetRequiredService <DataContext>(); var controller = new PaymentsController(context); context.Payment.Add(payment1); context.SaveChanges(); controller.DeletePayment(1); var card = controller.GetPaymentById(1).Result.Value; Assert.Null(card); }