public FinancialGuaranteeTests()
        {
            FinancialGuaranteeCollection = new FinancialGuaranteeCollection(NotificationId);
            FinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);

            CompletedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Status, FinancialGuaranteeStatus.ApplicationComplete, CompletedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.ReceivedDate, AnyDate, CompletedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.CompletedDate, CompletedDate, CompletedFinancialGuarantee);

            ApprovedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Status, FinancialGuaranteeStatus.Approved, ApprovedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Decision, FinancialGuaranteeDecision.Approved, ApprovedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.ReceivedDate, AnyDate, ApprovedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.CompletedDate, CompletedDate, ApprovedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.DecisionDate, AfterCompletionDate, ApprovedFinancialGuarantee);

            RefusedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Status, FinancialGuaranteeStatus.Refused, RefusedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Decision, FinancialGuaranteeDecision.Refused, RefusedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.ReceivedDate, AnyDate, RefusedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.CompletedDate, CompletedDate, RefusedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.DecisionDate, AfterCompletionDate, RefusedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.RefusalReason, AnyString, RefusedFinancialGuarantee);

            ReceivedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.Status, FinancialGuaranteeStatus.ApplicationReceived, ReceivedFinancialGuarantee);
            ObjectInstantiator<FinancialGuarantee>.SetProperty(fg => fg.ReceivedDate, AnyDate, ReceivedFinancialGuarantee);

            Dispatcher = A.Fake<IDeferredEventDispatcher>();
            DomainEvents.Dispatcher = Dispatcher;
        }
        private void AddFinancialGuarantees(Guid sourceId, Guid destinationId)
        {
            var sourceFinancialGuarantee      = new FinancialGuaranteeCollection(sourceId);
            var destinationFinancialGuarantee = new FinancialGuaranteeCollection(destinationId);

            context.FinancialGuarantees.Add(sourceFinancialGuarantee);
            context.FinancialGuarantees.Add(destinationFinancialGuarantee);
        }
Ejemplo n.º 3
0
        public async Task HandleAsync(NotificationCreatedEvent @event)
        {
            var notificationAssessment       = new NotificationAssessment(@event.Notification.Id);
            var financialGuaranteeCollection = new FinancialGuaranteeCollection(@event.Notification.Id);

            context.NotificationAssessments.Add(notificationAssessment);
            context.FinancialGuarantees.Add(financialGuaranteeCollection);

            await context.SaveChangesAsync();
        }
        public FinancialGuaranteeCollectionTests()
        {
            SystemTime.Freeze(today);

            financialGuaranteeCollection = new FinancialGuaranteeCollection(notificationId);

            var approvedFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-10));
            EntityHelper.SetEntityId(approvedFinancialGuarantee, approvedFinancialGuaranteeId);
            approvedFinancialGuarantee.Complete(today.AddDays(-9));
            approvedFinancialGuarantee.Approve(new ApprovalData(today.AddDays(-8), "123", 10, false));
        }
        public void Create_GeneratesObjectwithExpectedValues()
        {
            SystemTime.Freeze();

            var fg = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);

            Assert.Equal(SystemTime.UtcNow, fg.CreatedDate);
            Assert.Equal(FinancialGuaranteeStatus.ApplicationReceived, fg.Status);

            SystemTime.Unfreeze();
        }
        public FinancialGuaranteeCollectionTests()
        {
            SystemTime.Freeze(today);

            financialGuaranteeCollection = new FinancialGuaranteeCollection(notificationId);

            var approvedFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-10));

            EntityHelper.SetEntityId(approvedFinancialGuarantee, approvedFinancialGuaranteeId);
            approvedFinancialGuarantee.Complete(today.AddDays(-9));
            approvedFinancialGuarantee.Approve(new ApprovalData(today.AddDays(-8), "123", 10, false, (decimal)12.34, (decimal)56.78));
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
        public async Task FGDecisionMade_ReturnsFalse(FinancialGuaranteeStatus status)
        {
            var assessment = new NotificationAssessment(NotificationId);

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

            var financialGuaranteeCollection = new FinancialGuaranteeCollection(NotificationId);
            var financialGuarantee           = financialGuaranteeCollection.AddFinancialGuarantee(new DateTime(2015, 1, 1));

            ObjectInstantiator <FinancialGuarantee> .SetProperty(x => x.Status, status, financialGuarantee);

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

            var result = await service.Calculate(NotificationId);

            Assert.False(result);
        }
Ejemplo n.º 10
0
        public FinancialGuaranteeTests()
        {
            FinancialGuaranteeCollection = new FinancialGuaranteeCollection(NotificationId);
            FinancialGuarantee           = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);

            CompletedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Status, FinancialGuaranteeStatus.ApplicationComplete, CompletedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.ReceivedDate, AnyDate, CompletedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.CompletedDate, CompletedDate, CompletedFinancialGuarantee);

            ApprovedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Status, FinancialGuaranteeStatus.Approved, ApprovedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Decision, FinancialGuaranteeDecision.Approved, ApprovedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.ReceivedDate, AnyDate, ApprovedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.CompletedDate, CompletedDate, ApprovedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.DecisionDate, AfterCompletionDate, ApprovedFinancialGuarantee);

            RefusedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Status, FinancialGuaranteeStatus.Refused, RefusedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Decision, FinancialGuaranteeDecision.Refused, RefusedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.ReceivedDate, AnyDate, RefusedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.CompletedDate, CompletedDate, RefusedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.DecisionDate, AfterCompletionDate, RefusedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.RefusalReason, AnyString, RefusedFinancialGuarantee);

            ReceivedFinancialGuarantee = FinancialGuaranteeCollection.AddFinancialGuarantee(AnyDate);
            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.Status, FinancialGuaranteeStatus.ApplicationReceived, ReceivedFinancialGuarantee);

            ObjectInstantiator <FinancialGuarantee> .SetProperty(fg => fg.ReceivedDate, AnyDate, ReceivedFinancialGuarantee);

            Dispatcher = A.Fake <IDeferredEventDispatcher>();
            DomainEvents.Dispatcher = Dispatcher;
        }
        public FinancialGuaranteeApprovalTests()
        {
            SystemTime.Freeze(today);

            repository = A.Fake<IFinancialGuaranteeRepository>();

            financialGuaranteeCollection = new FinancialGuaranteeCollection(notificationId);

            var approvedFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-10));
            EntityHelper.SetEntityId(approvedFinancialGuarantee, approvedFinancialGuaranteeId);
            approvedFinancialGuarantee.Complete(today.AddDays(-9));
            approvedFinancialGuarantee.Approve(new ApprovalData(today.AddDays(-8), "123", 10, false));

            var newFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-5));
            newFinancialGuarantee.Complete(today.AddDays(-4));
            EntityHelper.SetEntityId(newFinancialGuarantee, financialGuaranteeId);

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(financialGuaranteeCollection);

            approval = new FinancialGuaranteeApproval(repository);
        }
        public FinancialGuaranteeApprovalTests()
        {
            SystemTime.Freeze(today);

            repository = A.Fake <IFinancialGuaranteeRepository>();

            financialGuaranteeCollection = new FinancialGuaranteeCollection(notificationId);

            var approvedFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-10));

            EntityHelper.SetEntityId(approvedFinancialGuarantee, approvedFinancialGuaranteeId);
            approvedFinancialGuarantee.Complete(today.AddDays(-9));
            approvedFinancialGuarantee.Approve(new ApprovalData(today.AddDays(-8), "123", 10, false, (decimal)12.34, (decimal)56.78));

            var newFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-5));

            newFinancialGuarantee.Complete(today.AddDays(-4));
            EntityHelper.SetEntityId(newFinancialGuarantee, financialGuaranteeId);

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(financialGuaranteeCollection);

            approval = new FinancialGuaranteeApproval(repository);
        }
        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;
        }