Example #1
0
        public async Task VoucherManagementACLApplicationService_GetVoucher_HttpRequestExceptionErrorInGetVoucher_GetVoucherNotSuccessful()
        {
            Mock <IVoucherManagementClient> voucherManagementClient = new Mock <IVoucherManagementClient>();

            voucherManagementClient.Setup(v => v.GetVoucher(It.IsAny <String>(), It.IsAny <Guid>(), It.IsAny <String>(), It.IsAny <CancellationToken>()))
            .ThrowsAsync(new Exception("Error", new HttpRequestException(TestData.HttpRequestErrorResponseMessage)));
            Mock <ISecurityServiceClient> securityServiceClient = new Mock <ISecurityServiceClient>();

            securityServiceClient.Setup(s => s.GetToken(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.TokenResponse);

            IVoucherManagementACLApplicationService applicationService =
                new Services.VoucherManagementACLApplicationService(securityServiceClient.Object, voucherManagementClient.Object);

            GetVoucherResponse voucherResponse = await applicationService.GetVoucher(TestData.EstateId, TestData.ContractId, TestData.VoucherCode, CancellationToken.None);

            voucherResponse.ShouldNotBeNull();
            voucherResponse.ResponseMessage.ShouldBe(TestData.HttpRequestErrorResponseMessage);
            voucherResponse.ResponseCode.ShouldBe(TestData.HttpRequestErrorResponseCode);
        }
Example #2
0
        public async Task VoucherManagementACLApplicationService_RedeemVoucher_VoucherRedeemed()
        {
            Mock <IVoucherManagementClient> voucherManagementClient = new Mock <IVoucherManagementClient>();

            voucherManagementClient.Setup(v => v.RedeemVoucher(It.IsAny <String>(), It.IsAny <RedeemVoucherRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(TestData.RedeemVoucherResponse);
            Mock <ISecurityServiceClient> securityServiceClient = new Mock <ISecurityServiceClient>();

            securityServiceClient.Setup(s => s.GetToken(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.TokenResponse);

            IVoucherManagementACLApplicationService applicationService =
                new Services.VoucherManagementACLApplicationService(securityServiceClient.Object, voucherManagementClient.Object);

            RedeemVoucherResponse voucherResponse = await applicationService.RedeemVoucher(TestData.EstateId, TestData.ContractId, TestData.VoucherCode, CancellationToken.None);

            voucherResponse.ShouldNotBeNull();
            voucherResponse.VoucherCode.ShouldBe(TestData.RedeemVoucherResponse.VoucherCode);
            voucherResponse.ContractId.ShouldBe(TestData.ContractId);
            voucherResponse.EstateId.ShouldBe(TestData.EstateId);
            voucherResponse.ExpiryDate.ShouldBe(TestData.RedeemVoucherResponse.ExpiryDate);
            voucherResponse.Balance.ShouldBe(TestData.RedeemVoucherResponse.RemainingBalance);
        }