public void CalledPostWithValidData() { var donation = new GiftAidDonation() { DonationAmount = 10, Name = "name", PostCode = "postCode" }; _donationRepository.RecordDonation(donation).Returns(new GiftAidDonation() { Id = Guid.NewGuid(), }); var result = _controller.Post(donation); var createdRequestResult = result as CreatedResult; Assert.IsNotNull(createdRequestResult); _donationRepository.Received().RecordDonation(donation); }
public async Task SaveDonor() { IGiftAidRepository aidRepository = new GiftAidRepository(_dbContext); GiftAidController controller = new GiftAidController(aidRepository, _calculationService, _declarationService); var donor = new Donor() { Id = Guid.NewGuid(), DonationAmount = 150, Name = "Pervaiz", PostCode = "LU49FS" }; var expected = 1.875; var actionResult = await controller.Post(donor); var okResult = actionResult as OkObjectResult; var actual = (GiftAidDeclarationResponse)okResult.Value; Assert.IsType <GiftAidDeclarationResponse>(actual); Assert.Equal(expected, actual.GiftAidAmount); }