コード例 #1
0
        public NotificationTransportRouteTests()
        {
            this.transportRoute = new TransportRoute(Guid.Empty);

            guids = new List <Guid>
            {
                new Guid("D8DB53F9-D3CB-498D-B044-7A67B94EE4E4"),
                new Guid("1D3A7A18-F345-4201-81AA-8FC8A4029F4E"),
                new Guid("596E6BE3-D0C1-4C17-AF75-BFCDBD972627"),
                new Guid("208EA94D-638B-4724-9272-DF1383FF9452"),
                new Guid("DEDAA6F6-CA6D-486E-B0B8-254A477E697F"),
                new Guid("4C7EEA30-510E-45BD-8DBB-3EC1AF5E563A"),
                new Guid("8B87B87D-43D0-4BBE-8E2C-8EC84C983A42"),
                new Guid("40E44905-4CDE-4470-8E8B-527EE65C65DC"),
                new Guid("58E18F1C-5A4A-4E2E-869F-72D9C1512FE8")
            };

            countries = guids.Select(g => CountryFactory.Create(g)).ToList();

            transitStates = new List <TransitState>();
            for (int i = 0; i < countries.Count - 1; i++)
            {
                var c = countries[i];
                transitStates.Add(new TransitState(c,
                                                   CompetentAuthorityFactory.Create(guids[i], c),
                                                   EntryOrExitPointFactory.Create(guids[i], c),
                                                   EntryOrExitPointFactory.Create(guids[i + 1], c), i + 1));
                ObjectInstantiator <TransitState> .SetProperty(x => x.Id, guids[i], transitStates[i]);
            }

            this.validator = A.Fake <ITransportRouteValidator>();
        }
コード例 #2
0
        public async Task NotificationNotConsented_Throws()
        {
            ObjectInstantiator <ImportNotificationAssessment> .SetProperty(x => x.Status,
                                                                           ImportNotificationStatus.FileClosed, assessment);

            await Assert.ThrowsAsync <InvalidOperationException>(() => factory.Create(notificationId, 1, shipmentDate, null));
        }
コード例 #3
0
        public async Task GetNotificationAssessmentByIdChecksAuthorization()
        {
            var notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery,
                                                                     UKCompetentAuthority.England, 20181);

            context.NotificationApplications.Add(notification);
            context.SaveChanges();

            var notificationId = notification.Id;

            var assessment = new NotificationAssessment(notificationId);

            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment);

            context.NotificationAssessments.Add(assessment);
            context.SaveChanges();

            var repository = new NotificationAssessmentRepository(context,
                                                                  notificationApplicationAuthorization);

            await repository.GetByNotificationId(notificationId);

            A.CallTo(() => notificationApplicationAuthorization.EnsureAccessAsync(notificationId)).MustHaveHappened();

            context.DeleteOnCommit(assessment);
            await context.SaveChangesAsync();

            context.DeleteOnCommit(notification);
            await context.SaveChangesAsync();
        }
コード例 #4
0
        private PricingStructure GetPricingStructure()
        {
            var pricingStructure = ObjectInstantiator <PricingStructure> .CreateNew();

            ObjectInstantiator <PricingStructure> .SetProperty(x => x.CompetentAuthority, UKCompetentAuthority.England, pricingStructure);

            var activity = A.Fake <Activity>();

            ObjectInstantiator <Activity> .SetProperty(x => x.TradeDirection, TradeDirection.Export, activity);

            ObjectInstantiator <Activity> .SetProperty(x => x.NotificationType, NotificationType.Recovery, activity);

            ObjectInstantiator <Activity> .SetProperty(x => x.IsInterim, false, activity);

            ObjectInstantiator <PricingStructure> .SetProperty(x => x.Activity, activity, pricingStructure);

            var shipmentQuantityRange = A.Fake <ShipmentQuantityRange>();

            ObjectInstantiator <ShipmentQuantityRange> .SetProperty(x => x.RangeFrom, LowerRange, shipmentQuantityRange);

            ObjectInstantiator <ShipmentQuantityRange> .SetProperty(x => x.RangeTo, UpperRange, shipmentQuantityRange);

            ObjectInstantiator <PricingStructure> .SetProperty(x => x.ShipmentQuantityRange, shipmentQuantityRange, pricingStructure);

            ObjectInstantiator <PricingStructure> .SetProperty(x => x.Price, NotificationPrice, pricingStructure);

            return(pricingStructure);
        }
コード例 #5
0
        public AddNotificationTransactionHandlerTests()
        {
            var chargeCalculator = A.Fake <INotificationChargeCalculator>();

            A.CallTo(() => chargeCalculator.GetValue(A <Guid> .Ignored)).Returns(TotalBillable);

            transactions = new List <NotificationTransaction>();
            var transactionRepository = A.Fake <INotificationTransactionRepository>();

            A.CallTo(() => transactionRepository.GetTransactions(NotificationId)).Returns(transactions);

            calculatorTransactions = new List <NotificationTransaction>();
            var calculatorRepository = A.Fake <INotificationTransactionRepository>();

            A.CallTo(() => calculatorRepository.GetTransactions(NotificationId)).Returns(calculatorTransactions);

            context.ShipmentInfos.Add(new TestableShipmentInfo {
                NotificationId = NotificationId
            });

            assessment = new NotificationAssessment(NotificationId);
            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment);

            context.NotificationAssessments.Add(assessment);

            context.NotificationApplications.Add(new TestableNotificationApplication {
                Id = NotificationId
            });

            var assessmentRepository = A.Fake <INotificationAssessmentRepository>();

            A.CallTo(() => assessmentRepository.GetByNotificationId(NotificationId)).Returns(assessment);

            handler = new AddNotificationTransactionHandler(context, new Transaction(assessmentRepository, transactionRepository, new NotificationTransactionCalculator(calculatorRepository, chargeCalculator)));
        }
コード例 #6
0
ファイル: MovementTests.cs プロジェクト: DEFRA/prsd-iws
        public void HasShipped_MovementSubmitted_ShipmentDateInFuture_ReturnsFalse()
        {
            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            ObjectInstantiator <Movement> .SetProperty(x => x.Date, AfterFrozenTime, movement);

            Assert.False(movement.HasShipped);
        }
コード例 #7
0
ファイル: MovementTests.cs プロジェクト: DEFRA/prsd-iws
        public void HasShipped_MovementSubmitted_ShipmentDateInPast_ReturnsTrue()
        {
            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            ObjectInstantiator <Movement> .SetProperty(x => x.Date, BeforeFrozenTime, movement);

            Assert.True(movement.HasShipped);
        }
コード例 #8
0
        private Domain.ImportNotificationAssessment.ImportNotificationAssessment CreateNotificationAssessment(Guid notificationApplicationId, ImportNotificationStatus status)
        {
            var assessment = new Domain.ImportNotificationAssessment.ImportNotificationAssessment(notificationApplicationId);

            ObjectInstantiator <Domain.ImportNotificationAssessment.ImportNotificationAssessment> .SetProperty(n => n.Status, status, assessment);

            return(assessment);
        }
コード例 #9
0
        private CompetentAuthority GetTestCompetentAuthority(Country country)
        {
            var competentAuthority = ObjectInstantiator <CompetentAuthority> .CreateNew();

            ObjectInstantiator <CompetentAuthority> .SetProperty(x => x.Country, country, competentAuthority);

            return(competentAuthority);
        }
コード例 #10
0
        private Country GetTestCountry(Guid id)
        {
            var country = ObjectInstantiator <Country> .CreateNew();

            ObjectInstantiator <Country> .SetProperty(x => x.Id, id, country);

            return(country);
        }
コード例 #11
0
        public async Task PaymentMadeButPaymentIncomplete_PaymentReceivedDateNull()
        {
            ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, existingDate, assessment.Dates);

            var incompletePayment = GetAddNotificationTransaction(existingDate, 50.00m, null);
            await handler.HandleAsync(incompletePayment);

            Assert.Null(context.NotificationAssessments.Single().Dates.PaymentReceivedDate);
        }
コード例 #12
0
        public MovementOperationReceiptTests()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0);

            movement = new Movement(1, notification.Id);
            ObjectInstantiator <Movement> .SetProperty(x => x.Date, MovementDate, movement);

            ObjectInstantiator <Movement> .SetProperty(x => x.Units, ShipmentQuantityUnits.Kilograms, movement);
        }
コード例 #13
0
        public async Task PaymentComplete_PaymentReceivedDateSet_UpdatesDateToAssessment()
        {
            ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, existingDate, assessment.Dates);

            var paymentComplete = GetAddNotificationTransaction(NewDate, TotalBillable, null);
            await handler.HandleAsync(paymentComplete);

            Assert.Equal(NewDate, context.NotificationAssessments.Single().Dates.PaymentReceivedDate);
        }
        public async Task Handler_NotificationHasExitCustomsOffice_ReturnsAllData()
        {
            ObjectInstantiator <TransportRoute> .SetProperty(x => x.ExitCustomsOffice, exitCustomsOffice, transport);

            var result = await handler.HandleAsync(new GetExitCustomsOfficeAddDataByNotificationId(NotificationId));

            Assert.Equal(1, result.Countries.Count);
            Assert.Equal(exitCustomsOffice.Name, result.CustomsOfficeData.Name);
            Assert.NotNull(result.CustomsOffices);
        }
コード例 #15
0
        public void CanSetCommencementDateWhenReceived_SetsNameOfOfficer()
        {
            SetNotificationStatus(NotificationStatus.NotificationReceived);

            ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, receivedDate, notificationAssessment.Dates);

            notificationAssessment.Commenced(commencementDate, nameOfOfficer);

            Assert.Equal(nameOfOfficer, notificationAssessment.Dates.NameOfOfficer);
        }
コード例 #16
0
        public void SetCommencementDateUpdatesStatusToInAssessment()
        {
            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, notificationAssessment);

            ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, receivedDate, notificationAssessment.Dates);

            notificationAssessment.Commenced(commencementDate, nameOfOfficer);

            Assert.Equal(NotificationStatus.InAssessment, notificationAssessment.Status);
        }
コード例 #17
0
        public void SetCommencementDate_NameOfOfficerCantBeEmpty()
        {
            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, notificationAssessment);

            ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, receivedDate, notificationAssessment.Dates);

            Action setCommencementDate = () => notificationAssessment.Commenced(commencementDate, string.Empty);

            Assert.Throws <ArgumentException>("nameOfOfficer", setCommencementDate);
        }
コード例 #18
0
        private ImportNotification CreateImportNotification(NotificationType notificationType, Guid importNotificationId)
        {
            var instance = ObjectInstantiator <ImportNotification> .CreateNew();

            EntityHelper.SetEntityId(instance, importNotificationId);
            ObjectInstantiator <ImportNotification> .SetProperty(x => x.NotificationType, notificationType,
                                                                 instance);

            return(instance);
        }
コード例 #19
0
        public async Task MovementStatusNotSubmitted_Throws(MovementStatus status)
        {
            var movement = new Movement(1, NotificationId, Today, AnyGuid);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, status, movement);

            var validDate = Today.AddDays(3);

            await Assert.ThrowsAsync <MovementDateException>(() =>
                                                             updatedDateValidator.EnsureDateValid(movement, validDate));
        }
コード例 #20
0
        public SetNotificationReceivedDateHandlerTests()
        {
            context    = new TestIwsContext();
            assessment = new NotificationAssessment(notificationId);
            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.Submitted, assessment);

            context.NotificationAssessments.Add(assessment);

            handler = new SetNotificationReceivedDateHandler(context);
            message = new SetNotificationReceivedDate(notificationId, notificationReceivedDate);
        }
コード例 #21
0
        private static FinancialGuaranteeCollection GetFinancialGuarantee()
        {
            var collection = new FinancialGuaranteeCollection(NotificationId);

            var fg = collection.AddFinancialGuarantee(new DateTime(2015, 1, 1));

            ObjectInstantiator <FinancialGuarantee> .SetProperty(f => f.ActiveLoadsPermitted, 2, fg);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(f => f.Status, FinancialGuaranteeStatus.Approved, fg);

            return(collection);
        }
コード例 #22
0
        public async Task Date10WorkingsDaysGreaterThanOriginalDate_Throws()
        {
            var movement = new Movement(1, NotificationId, Today, AnyGuid);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            //10 workings days after 1 Jan 2015 is 14 calendar days (only counting weekends)...
            var newDate = Today.AddDays(15);

            await Assert.ThrowsAsync <MovementDateOutOfRangeOfOriginalDateException>(() =>
                                                                                     updatedDateValidator.EnsureDateValid(movement, newDate));
        }
コード例 #23
0
        private static FinancialGuaranteeCollection GetFinancialGuarantee(FinancialGuaranteeStatus status)
        {
            var collection = new FinancialGuaranteeCollection(NotificationId);

            var fg = collection.AddFinancialGuarantee(Today);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(f => f.ActiveLoadsPermitted, 2, fg);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(f => f.Status, status, fg);

            return(collection);
        }
コード例 #24
0
ファイル: MovementDateTests.cs プロジェクト: DEFRA/prsd-iws
        public async Task DateChangedRaisesEvent()
        {
            var movement = new Movement(1, NotificationId, Today, userId);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            var newDate = Today.AddDays(5);

            await movement.UpdateDate(newDate, validator);

            Assert.NotNull(movement.Events.OfType <MovementDateChangeEvent>().SingleOrDefault());
        }
コード例 #25
0
        public async Task ValidDate_DoesNotThrow()
        {
            var movement = new Movement(1, NotificationId, Today, AnyGuid);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            var validDate = Today.AddDays(3);

            await updatedDateValidator.EnsureDateValid(movement, validDate);

            // No assert required
        }
コード例 #26
0
ファイル: MovementDateTests.cs プロジェクト: DEFRA/prsd-iws
        public async Task DateUpdates()
        {
            var movement = new Movement(1, NotificationId, Today, userId);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            var newDate = Today.AddDays(13);

            await movement.UpdateDate(newDate, validator);

            Assert.Equal(newDate, movement.Date);
        }
コード例 #27
0
ファイル: MovementDateTests.cs プロジェクト: DEFRA/prsd-iws
        public async Task DateChangedEvent_ContainsOldDate()
        {
            var initialDate = Today;
            var movement    = new Movement(1, NotificationId, initialDate, userId);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            var newDate = initialDate.AddDays(5);

            await movement.UpdateDate(newDate, validator);

            Assert.Equal(initialDate, movement.Events.OfType <MovementDateChangeEvent>().Single().PreviousDate);
        }
コード例 #28
0
ファイル: MovementDateTests.cs プロジェクト: DEFRA/prsd-iws
        public async Task DateNotValid_Throws()
        {
            var initialDate = Today;
            var movement    = new Movement(1, NotificationId, initialDate, userId);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, MovementStatus.Submitted, movement);

            A.CallTo(() => validator.EnsureDateValid(movement, A <DateTime> .Ignored)).Throws <MovementDateException>();

            var newDate = initialDate.AddDays(5);

            await Assert.ThrowsAsync <MovementDateException>(() => movement.UpdateDate(newDate, validator));
        }
コード例 #29
0
        private EntryOrExitPoint GetTestEntryOrExitPoint(Country country, Guid?id = null)
        {
            var entryOrExitPoint = ObjectInstantiator <EntryOrExitPoint> .CreateNew();

            ObjectInstantiator <EntryOrExitPoint> .SetProperty(x => x.Country, country, entryOrExitPoint);

            if (id != null)
            {
                ObjectInstantiator <EntryOrExitPoint> .SetProperty(x => x.Id, (Guid)id, entryOrExitPoint);
            }

            return(entryOrExitPoint);
        }
コード例 #30
0
        public async Task GetNotificationDatesSummaryByIdChecksAuthorization()
        {
            var notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery,
                                                                     UKCompetentAuthority.England, 20181);

            context.NotificationApplications.Add(notification);
            context.SaveChanges();

            var notificationId = notification.Id;

            var decisionRequiredBy = new DecisionRequiredBy(A.Fake <IDecisionRequiredByCalculator>(),
                                                            A.Fake <IFacilityRepository>());
            var assessmentRepository  = A.Fake <INotificationAssessmentRepository>();
            var applicationRepository = A.Fake <INotificationApplicationRepository>();
            var transactionCalculator = A.Fake <INotificationTransactionCalculator>();
            var assessment            = new NotificationAssessment(notificationId);

            ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment);

            A.CallTo(() => assessmentRepository.GetByNotificationId(notificationId))
            .Returns(assessment);
            A.CallTo(() => applicationRepository.GetById(notificationId)).Returns(notification);

            var transaction = new NotificationTransaction(
                new NotificationTransactionData
            {
                Credit         = 1,
                Date           = new DateTime(2017, 1, 1),
                NotificationId = notificationId,
                PaymentMethod  = PaymentMethod.Card
            });

            A.CallTo(() => transactionCalculator.PaymentReceivedDate(notificationId))
            .Returns(transaction);
            A.CallTo(() => transactionCalculator.LatestPayment(notificationId))
            .Returns(transaction);
            A.CallTo(() => transactionCalculator.IsPaymentComplete(notificationId)).Returns(true);

            var repository = new NotificationAssessmentDatesSummaryRepository(decisionRequiredBy,
                                                                              assessmentRepository,
                                                                              applicationRepository,
                                                                              transactionCalculator,
                                                                              notificationApplicationAuthorization);

            await repository.GetById(notificationId);

            A.CallTo(() => notificationApplicationAuthorization.EnsureAccessAsync(notificationId)).MustHaveHappened();

            context.DeleteOnCommit(notification);
            await context.SaveChangesAsync();
        }