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 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 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); }
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; } }
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 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); }
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); }
public MovementOperationBlock(IList <MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed) : base(mergeFields, notification, technologyEmployed) { }