public async Task GetCurrentPaymentMethod_ActivePaymentMethodDoesNotExist_NullReturned() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <GetActivePaymentMethodForUserQuery>()) .Returns((PaymentMethod)null); var mapper = AutoMapperFactory.CreateValidMapper(); var controller = new PaymentController( fakeMediator, mapper); controller.FakeAuthentication("some-identity-name"); //Act var paymentMethodResponse = await controller.GetCurrentPaymentMethod(); //Assert var paymentMethod = paymentMethodResponse.ToObject <PaymentMethodResponse>(); Assert.IsNull(paymentMethod); }
public async Task AddPaymentMethod_UserSignedIn_SetsActivePaymentMethodForUser() { //Arrange var fakeMediator = Substitute.For <IMediator>(); var mapper = AutoMapperFactory.CreateValidMapper(); var controller = new PaymentController( fakeMediator, mapper); controller.FakeAuthentication("some-identity-name"); //Act await controller.AddPaymentMethod("some-payment-method-id"); //Assert await fakeMediator .Received(1) .Send(Arg.Is <SetActivePaymentMethodForUserCommand>(arg => arg.PaymentMethodId == "some-payment-method-id")); }