Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
            }
        }
        public void TechnologyDetailsCannotBeMoreThan70CharactersLong()
        {
            const string longString = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            Action       createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, longString, "Details");

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

            technologyEmployed.SetWithAnnex("details");

            Assert.Equal(true, technologyEmployed.AnnexProvided);
        }
        public void CanUpdateTechnologyEmployedDetails()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details");

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

            Assert.Equal("new details", technologyEmployed.Details);
        }
Ejemplo n.º 6
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);
        }
        public void TechnologyDetailsCannotBeEmpty()
        {
            Action createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, string.Empty, string.Empty);

            Assert.Throws <ArgumentException>("details", createTechnologyEmployed);
        }
        public void TechnologyDetailsCannotBeNull()
        {
            Action createTechnologyEmployed = () => TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, null, null);

            Assert.Throws <ArgumentNullException>("details", createTechnologyEmployed);
        }
        public void AddTechnologyEmployedDetails_AnnexProvidedIsFalse()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "text area contents", "further details");

            Assert.False(technologyEmployed.AnnexProvided);
        }
        public void CanAddTechnologyEmployedDetails()
        {
            var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "text area contents", "further details");

            Assert.Equal(technologyEmployed.Details, "text area contents");
        }