Exemplo n.º 1
0
        public async Task BillingService_Us_ShouldBeAddInvoiceWithoutPeriodicityProperty_WhenClientIsMonthly()
        {
            var timeZoneConfigurations = new TimeZoneConfigurations
            {
                InvoicesTimeZone = TimeZoneHelper.GetTimeZoneByOperativeSystem("Argentina Standard Time")
            };

            var billingMappers = new List <IBillingMapper>
            {
                new BillingForUsMapper(Mock.Of <ISapBillingItemsService>(),
                                       Mock.Of <IDateTimeProvider>(),
                                       timeZoneConfigurations),
            };

            var slackServiceMock = new Mock <ISlackService>();

            slackServiceMock.Setup(x => x.SendNotification(It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            var queuingServiceMock = new Mock <IQueuingService>();

            var billingValidations = new List <IBillingValidation>
            {
                new BillingForUsValidation(Mock.Of <ILogger <BillingForUsValidation> >())
            };

            var billingService = new BillingService(queuingServiceMock.Object,
                                                    Mock.Of <IDateTimeProvider>(),
                                                    Mock.Of <ILogger <BillingService> >(),
                                                    slackServiceMock.Object,
                                                    billingMappers,
                                                    billingValidations,
                                                    Mock.Of <ISapServiceSettingsFactory>());

            var billingRequestList = new List <BillingRequest>
            {
                new BillingRequest
                {
                    Id = 1,
                    BillingSystemId = 2,
                    FiscalID        = "123",
                    Periodicity     = 0,
                    PlanFee         = 15
                }
            };

            // Act
            await billingService.CreateBillingRequest(billingRequestList);

            // Assert
            queuingServiceMock.Verify(x => x.AddToTaskQueue(
                                          It.Is <SapTask>(y => y.BillingRequest.DocumentLines.FirstOrDefault()
                                                          .FreeText == "$ 15 -  Monthly Plan  - Period 00 0")),
                                      Times.Once);
        }
Exemplo n.º 2
0
        public async Task BillingService_ShouldBeAddOneTaskInQueue_WhenBillingRequestListHasOneInvalidCountryCodeElement()
        {
            var sapConfigMock          = new Mock <IOptions <SapConfig> >();
            var timeZoneConfigurations = new TimeZoneConfigurations
            {
                InvoicesTimeZone = TimeZoneHelper.GetTimeZoneByOperativeSystem("Argentina Standard Time")
            };
            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.UtcNow)
            .Returns(new DateTime(2019, 09, 25));

            var billingMappers = new List <IBillingMapper>
            {
                new BillingForArMapper(Mock.Of <ISapBillingItemsService>(), dateTimeProviderMock.Object, timeZoneConfigurations),
                new BillingForUsMapper(Mock.Of <ISapBillingItemsService>(), dateTimeProviderMock.Object, timeZoneConfigurations)
            };

            var slackServiceMock = new Mock <ISlackService>();

            slackServiceMock.Setup(x => x.SendNotification(It.IsAny <string>())).Returns(Task.CompletedTask);

            var queuingServiceMock = new Mock <IQueuingService>();

            var billingService = new BillingService(queuingServiceMock.Object,
                                                    dateTimeProviderMock.Object,
                                                    Mock.Of <ILogger <BillingService> >(),
                                                    slackServiceMock.Object,
                                                    billingMappers,
                                                    null);

            var billingRequestList = new List <BillingRequest>
            {
                new BillingRequest
                {
                    BillingSystemId = 16,
                    FiscalID        = "123"
                }
            };

            await billingService.CreateBillingRequest(billingRequestList);

            queuingServiceMock.Verify(x => x.AddToTaskQueue(It.IsAny <SapTask>()), Times.Never);
            slackServiceMock.Verify(x => x.SendNotification(It.IsAny <string>()), Times.Once);
        }
Exemplo n.º 3
0
        public async Task BillingService_ShouldBeAddOneTaskInQueue_WhenBillingRequestListHasOneValidElement()
        {
            var itemCode = "1.0.1";
            var items    = new List <BillingItemPlanDescriptionModel>
            {
                new BillingItemPlanDescriptionModel
                {
                    ItemCode    = "1.0.1",
                    description = "Test"
                }
            };

            var billingValidations = new List <IBillingValidation>
            {
                new BillingForArValidation(Mock.Of <ILogger <BillingForArValidation> >()),
                new BillingForUsValidation(Mock.Of <ILogger <BillingForUsValidation> >())
            };

            var sapConfigMock          = new Mock <IOptions <SapConfig> >();
            var timeZoneConfigurations = new TimeZoneConfigurations
            {
                InvoicesTimeZone = TimeZoneHelper.GetTimeZoneByOperativeSystem("Argentina Standard Time")
            };
            var sapBillingItemsServiceMock = new Mock <ISapBillingItemsService>();

            sapBillingItemsServiceMock.Setup(x => x.GetItemCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(itemCode);
            sapBillingItemsServiceMock.Setup(x => x.GetItems(It.IsAny <int>())).Returns(items);

            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.UtcNow)
            .Returns(new DateTime(2019, 09, 25));

            var billingMappers = new List <IBillingMapper>
            {
                new BillingForArMapper(sapBillingItemsServiceMock.Object, dateTimeProviderMock.Object, timeZoneConfigurations),
                new BillingForUsMapper(sapBillingItemsServiceMock.Object, dateTimeProviderMock.Object, timeZoneConfigurations)
            };

            var queuingServiceMock = new Mock <IQueuingService>();
            var billingService     = new BillingService(queuingServiceMock.Object,
                                                        dateTimeProviderMock.Object,
                                                        Mock.Of <ILogger <BillingService> >(),
                                                        Mock.Of <ISlackService>(),
                                                        billingMappers,
                                                        billingValidations);

            var billingRequestList = new List <BillingRequest>
            {
                new BillingRequest
                {
                    BillingSystemId = 9,
                    Id       = 1,
                    FiscalID = "123"
                }
            };

            await billingService.CreateBillingRequest(billingRequestList);

            queuingServiceMock.Verify(x => x.AddToTaskQueue(It.IsAny <SapTask>()), Times.Once);
        }