Пример #1
0
        private async Task CloneTechnologyEmployed(Guid sourceNotificationId, Guid destinationNotificationId)
        {
            var technologyEmployed =
                await context.TechnologiesEmployed.SingleOrDefaultAsync(p => p.NotificationId == sourceNotificationId);

            if (technologyEmployed != null)
            {
                TechnologyEmployed destinationTechnologyEmployed;

                if (technologyEmployed.AnnexProvided)
                {
                    destinationTechnologyEmployed =
                        TechnologyEmployed.CreateTechnologyEmployedWithAnnex(destinationNotificationId,
                                                                             technologyEmployed.Details);
                }
                else
                {
                    destinationTechnologyEmployed =
                        TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(
                            destinationNotificationId,
                            technologyEmployed.Details,
                            technologyEmployed.FurtherDetails);
                }

                context.TechnologiesEmployed.Add(destinationTechnologyEmployed);

                await context.SaveChangesAsync();
            }
        }
Пример #2
0
        public OperationBlock(IList<MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new OperationViewModel(notification, technologyEmployed, new OperationInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
Пример #3
0
        public async Task <Guid> HandleAsync(SetTechnologyEmployed command)
        {
            var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(command.NotificationId);

            if (technologyEmployed == null)
            {
                technologyEmployed = command.AnnexProvided
                    ? TechnologyEmployed.CreateTechnologyEmployedWithAnnex(command.NotificationId, command.Details)
                    : TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(command.NotificationId,
                                                                                    command.Details, command.FurtherDetails);

                context.TechnologiesEmployed.Add(technologyEmployed);
            }
            else
            {
                if (command.AnnexProvided)
                {
                    technologyEmployed.SetWithAnnex(command.Details);
                }
                else
                {
                    technologyEmployed.SetWithFurtherDetails(command.Details, command.FurtherDetails);
                }
            }

            await context.SaveChangesAsync();

            return(technologyEmployed.Id);
        }
        public void TechnologyDetailsCannotBeMoreThan70CharactersLong()
        {
            const string longString = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            Action       createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, longString, "Details");

            Assert.Throws <InvalidOperationException>(createTechnologyEmployed);
        }
        public void CanUpdateTechnologyEmployedDetails()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details");

            technologyEmployed.SetWithFurtherDetails("new details", "further details");

            Assert.Equal("new details", technologyEmployed.Details);
        }
        public void CanUpdateTechnologyEmployedAnnexProvided()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details");

            technologyEmployed.SetWithAnnex("details");

            Assert.Equal(true, technologyEmployed.AnnexProvided);
        }
Пример #7
0
        public async Task TechnologyEmployedRequired()
        {
            technologyEmployed = new TestableTechnologyEmployed
            {
                AnnexProvided = true
            };

            A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId))
            .Returns(technologyEmployed);

            var result = await requiredAnnexes.Get(notificationId);

            Assert.True(result.IsTechnologyEmployedRequired);
        }
        public async Task TechnologyEmployedRequired()
        {
            technologyEmployed = new TestableTechnologyEmployed
            {
                AnnexProvided = true
            };

            A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId))
                .Returns(technologyEmployed);

            var result = await requiredAnnexes.Get(notificationId);

            Assert.True(result.IsTechnologyEmployedRequired);
        }
        public RequiredAnnexesTests()
        {
            var notificationApplicationRepository = A.Fake<INotificationApplicationRepository>();
            technologyEmployedRepository = A.Fake<ITechnologyEmployedRepository>();

            notification = new TestableNotificationApplication();
            notification.Id = notificationId;
            technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details");

            A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification);

            A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId))
                .Returns(technologyEmployed);

            requiredAnnexes = new RequiredAnnexes(notificationApplicationRepository, technologyEmployedRepository);
        }
        public OperationViewModel(NotificationApplication notification, TechnologyEmployed technologyEmployed, OperationInfoFormatter formatter)
        {
            if (notification == null)
            {
                return;
            }

            reasonForExport = notification.ReasonForExport ?? string.Empty;
            OperationCodes = formatter.OperationInfosToCommaDelimitedList(notification.OperationInfos);

            if (technologyEmployed != null)
            {
                IsAnnexProvided = technologyEmployed.AnnexProvided;
                technologyEmployedDetails = technologyEmployed.Details ?? string.Empty;
                furtherDetails = technologyEmployed.FurtherDetails ?? string.Empty;
            }
        }
Пример #11
0
        public RequiredAnnexesTests()
        {
            var notificationApplicationRepository = A.Fake <INotificationApplicationRepository>();

            technologyEmployedRepository = A.Fake <ITechnologyEmployedRepository>();

            notification       = new TestableNotificationApplication();
            notification.Id    = notificationId;
            technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details");

            A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification);

            A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId))
            .Returns(technologyEmployed);

            requiredAnnexes = new RequiredAnnexes(notificationApplicationRepository, technologyEmployedRepository);
        }
Пример #12
0
        public OperationViewModel(NotificationApplication notification, TechnologyEmployed technologyEmployed, OperationInfoFormatter formatter)
        {
            if (notification == null)
            {
                return;
            }

            reasonForExport = notification.ReasonForExport ?? string.Empty;
            OperationCodes  = formatter.OperationInfosToCommaDelimitedList(notification.OperationInfos);

            if (technologyEmployed != null)
            {
                IsAnnexProvided           = technologyEmployed.AnnexProvided;
                technologyEmployedDetails = technologyEmployed.Details ?? string.Empty;
                furtherDetails            = technologyEmployed.FurtherDetails ?? string.Empty;
            }
        }
 public MovementOperationBlock(IList<MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed) 
     : base(mergeFields, notification, technologyEmployed)
 {
 }
        private void AddTechnologyEmployed(Guid id)
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithAnnex(id, "test");

            context.TechnologiesEmployed.Add(technologyEmployed);
        }
        public void CanAddTechnologyEmployedDetails()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "text area contents", "further details");

            Assert.Equal(technologyEmployed.Details, "text area contents");
        }
        public void AddTechnologyEmployedDetails_AnnexProvidedIsFalse()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "text area contents", "further details");

            Assert.False(technologyEmployed.AnnexProvided);
        }
        public void CanAddTechnologyDetailsInAnnex()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithAnnex(notificationId, "details");

            Assert.True(technologyEmployed.AnnexProvided);
        }
Пример #18
0
        public OperationBlock(IList <MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new OperationViewModel(notification, technologyEmployed, new OperationInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
        public void TechnologyDetailsCannotBeNull()
        {
            Action createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, null, null);

            Assert.Throws <ArgumentNullException>("details", createTechnologyEmployed);
        }
        public void TechnologyDetailsCannotBeEmpty()
        {
            Action createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, string.Empty, string.Empty);

            Assert.Throws <ArgumentException>("details", createTechnologyEmployed);
        }
Пример #21
0
 public MovementOperationBlock(IList <MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed)
     : base(mergeFields, notification, technologyEmployed)
 {
 }