Esempio n. 1
0
        public async Task GetDeclarationShouldReturnDeclarationData()
        {
            var testRequest = new GetDeclarationRequest
            {
                Id = "123456789012345678901234"
            };

            var expectedResponse = new GetDeclarationResponse
            {
                Id             = "123456789012345678901234",
                Name           = "Nerijus",
                PostCode       = "testPostCode",
                DonationAmount = 800,
                GiftAidAmount  = 200
            };

            _donationDeclarationServiceMock.Setup(x => x.Get(new ObjectId("123456789012345678901234")))
            .Returns(new DonationDeclaration
            {
                Id             = new ObjectId("123456789012345678901234"),
                Name           = "Nerijus",
                PostCode       = "testPostCode",
                DonationAmount = 800
            });

            var controller = new GiftAidController(_optionsMonitorMock.Object, _giftAidCalculatorMock.Object, _donationDeclarationServiceMock.Object);

            var response        = controller.GetDonationDeclaration(testRequest);
            var responseContext = response as ObjectResult;

            Assert.AreEqual(expectedResponse.ToString(), responseContext.Value.ToString());
        }
Esempio n. 2
0
        public async Task GetDeclarationShouldReturnIdLengthValidationError()
        {
            var testRequest = new GetDeclarationRequest
            {
                Id = "12345"
            };

            var controller = new GiftAidController(_optionsMonitorMock.Object, _giftAidCalculatorMock.Object, _donationDeclarationServiceMock.Object);

            Assert.Throws <ArgumentException>(() => controller.GetDonationDeclaration(testRequest));
        }
Esempio n. 3
0
        public async Task GetDeclarationShouldReturnNotFoundCodeWhenGivenIdIsInvalid()
        {
            var testRequest = new GetDeclarationRequest
            {
                Id = "123456789012345678901234"
            };

            _donationDeclarationServiceMock.Setup(x => x.Get(new ObjectId("123456789012345678901234")))
            .Returns((DonationDeclaration)null);

            var controller = new GiftAidController(_optionsMonitorMock.Object, _giftAidCalculatorMock.Object, _donationDeclarationServiceMock.Object);

            var response        = controller.GetDonationDeclaration(testRequest);
            var responseContext = response as ObjectResult;

            Assert.AreEqual(404, responseContext.StatusCode);
        }