protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var step = AddJourneyWithStep(context, "J", "S", AddMode(context, "M", false), AddResponsible(context, "R")).Steps.First(); var notClosedProject = AddProject(context, ProjectNameNotClosed, "Project description"); var closedProject = AddProject(context, ProjectNameClosed, "Project description", true); var rd = AddRequirementTypeWith1DefWithoutField(context, "T", "D", RequirementTypeIcon.Other).RequirementDefinitions.First(); var req = new TagRequirement(TestPlant, 2, rd); var t1 = AddTag(context, notClosedProject, TagType.Standard, "T1", "Tag description", step, new List <TagRequirement> { req }); _tag1InNotClosedProjectId = t1.Id; var t2 = AddTag(context, notClosedProject, TagType.Standard, "T2", "Tag description", step, new List <TagRequirement> { req }); _tag2InNotClosedProjectId = t2.Id; var t3 = AddTag(context, closedProject, TagType.Standard, "T3", "Tag description", step, new List <TagRequirement> { req }); _tagInClosedProjectId = t3.Id; } }
public void Setup() { var tagId = 2; var projectRepositoryMock = new Mock <IProjectRepository>(); var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var rdMock = new Mock <RequirementDefinition>(); rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); var requirement = new TagRequirement(TestPlant, 2, rdMock.Object); _tag = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { requirement }); projectRepositoryMock .Setup(r => r.GetTagByTagIdAsync(tagId)) .Returns(Task.FromResult(_tag)); _command = new VoidTagCommand(tagId, _rowVersion); _dut = new VoidTagCommandHandler( projectRepositoryMock.Object, UnitOfWorkMock.Object); }
public void Setup() { // Arrange var _stepMock = new Mock <Step>(); _stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var _rdMock = new Mock <RequirementDefinition>(); _rdMock.SetupGet(rd => rd.Id).Returns(2); _rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); _projectRepositoryMock = new Mock <IProjectRepository>(); var requirement = new TagRequirement(TestPlant, 2, _rdMock.Object); _tag = new Tag(TestPlant, TagType.Standard, "", "", _stepMock.Object, new List <TagRequirement> { requirement }); _tag.SetProtectedIdForTesting(2); _tag.IsVoided = true; _project = new Project(TestPlant, _projectName, ""); _project.AddTag(_tag); _projectRepositoryMock .Setup(x => x.GetProjectByTagIdAsync(_tag.Id)) .Returns(Task.FromResult(_project)); _command = new DeleteTagCommand(_tagId, _rowVersion); _dut = new DeleteTagCommandHandler(_projectRepositoryMock.Object, UnitOfWorkMock.Object); }
private static void RecordCheckBoxValues(List <CheckBoxFieldValue> values, TagRequirement requirement, RequirementDefinition requirementDefinition) { var checkBoxValues = values.ToDictionary(keySelector => keySelector.FieldId, elementSelector => elementSelector.IsChecked); requirement.RecordCheckBoxValues(checkBoxValues, requirementDefinition); }
public void Setup() { _projectRepositoryMock = new Mock <IProjectRepository>(); var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var _rdMock = new Mock <RequirementDefinition>(); _rdMock.SetupGet(rd => rd.Id).Returns(_rdId1); _rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); var requirement = new TagRequirement(TestPlant, _intervalWeeks, _rdMock.Object); _tag = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { requirement }); _projectRepositoryMock .Setup(r => r.GetTagByTagIdAsync(_tagId)) .Returns(Task.FromResult(_tag)); _command = new CreateActionCommand(_tagId, _title, _description, _dueTimeUtc); _dut = new CreateActionCommandHandler( _projectRepositoryMock.Object, UnitOfWorkMock.Object, PlantProviderMock.Object ); }
public void Setup() { _projectRepositoryMock = new Mock <IProjectRepository>(); var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var rdMock = new Mock <RequirementDefinition>(); rdMock.SetupGet(rd => rd.Id).Returns(_rdId1); rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); _requirement = new TagRequirement(TestPlant, _intervalWeeks, rdMock.Object); _tag = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _requirement }) { StorageArea = _oldStorageArea, Remark = _oldRemark }; var tagId = 2; _projectRepositoryMock .Setup(r => r.GetTagByTagIdAsync(tagId)) .Returns(Task.FromResult(_tag)); _command = new UpdateTagCommand(tagId, _newRemark, _newStorageArea, _rowVersion); _dut = new UpdateTagCommandHandler( _projectRepositoryMock.Object, UnitOfWorkMock.Object); }
private static void RecordNumberValues(List <NumberFieldValue> values, TagRequirement requirement, RequirementDefinition requirementDefinition) { var numberValues = values.Where(nv => !nv.IsNa).ToDictionary( keySelector => keySelector.FieldId, elementSelector => elementSelector.Value); requirement.RecordNumberValues(numberValues, requirementDefinition); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider); _uri = new Uri("http://whatever/file.txt"); _attachmentOptionsMock = new Mock <IOptionsMonitor <AttachmentOptions> >(); var options = new AttachmentOptions { BlobContainer = BlobContainer }; _attachmentOptionsMock .Setup(x => x.CurrentValue) .Returns(options); var journey = AddJourneyWithStep(context, "J1", "S", AddMode(context, "M1", false), AddResponsible(context, "R1")); var reqDef = AddRequirementTypeWith1DefWithoutField(context, "T1", "D1", RequirementTypeIcon.Other).RequirementDefinitions.Single(); var attachmentField = new Field(TestPlant, "Label", FieldType.Attachment, 0); reqDef.AddField(attachmentField); context.SaveChangesAsync().Wait(); var requirement = new TagRequirement(TestPlant, 2, reqDef); var tag = new Tag(TestPlant, TagType.Standard, "TagNo", "Description", journey.Steps.ElementAt(0), new List <TagRequirement> { requirement }); context.Tags.Add(tag); tag.StartPreservation(); context.SaveChangesAsync().Wait(); _tagId = tag.Id; _requirementId = requirement.Id; _attachmentFieldId = attachmentField.Id; var fieldValueAttachment = new FieldValueAttachment(TestPlant, Guid.Empty, "FilA.txt"); requirement.RecordAttachment(fieldValueAttachment, _attachmentFieldId, reqDef); context.SaveChangesAsync().Wait(); var fullBlobPath = fieldValueAttachment.GetFullBlobPath(BlobContainer); _blobStorageMock = new Mock <IBlobStorage>(); _blobStorageMock .Setup(b => b.GetDownloadSasUri(fullBlobPath, It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>())) .Returns(_uri); }
public void Setup() { var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); _rd1Mock = new Mock <RequirementDefinition>(); _rd1Mock.SetupGet(rd => rd.Id).Returns(_rdId1); _rd1Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _rd2Mock = new Mock <RequirementDefinition>(); _rd2Mock.SetupGet(rd => rd.Id).Returns(_rdId2); _rd2Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _req1OnTag1 = new TagRequirement(TestPlant, 1, _rd1Mock.Object); _req2OnTag1 = new TagRequirement(TestPlant, 2, _rd2Mock.Object); _req1OnTag2 = new TagRequirement(TestPlant, 3, _rd1Mock.Object); _req2OnTag2 = new TagRequirement(TestPlant, 4, _rd2Mock.Object); _tag1 = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _req1OnTag1, _req2OnTag1 }); _tag1.StartPreservation(); _tag1.SetProtectedIdForTesting(_tagId1); _tag2 = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _req1OnTag2, _req2OnTag2 }); _tag2.StartPreservation(); _tag2.SetProtectedIdForTesting(_tagId2); var tags = new List <Tag> { _tag1, _tag2 }; var tagIds = new List <int> { _tagId1, _tagId2 }; var tagIdsWithRowVersion = new List <IdAndRowVersion> { new IdAndRowVersion(_tagId1, _rowVersion1), new IdAndRowVersion(_tagId2, _rowVersion2) }; _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagsByTagIdsAsync(tagIds)).Returns(Task.FromResult(tags)); _rescheduleOneWeekLaterCommand = new RescheduleCommand(tagIdsWithRowVersion, 1, RescheduledDirection.Later, "Comment"); _rescheduleFourWeeksEarlierCommand = new RescheduleCommand(tagIdsWithRowVersion, 4, RescheduledDirection.Earlier, "Comment"); _dut = new RescheduleCommandHandler(_projectRepoMock.Object, UnitOfWorkMock.Object); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var journey = AddJourneyWithStep(context, "J1", "S", AddMode(context, "M1", false), AddResponsible(context, "R1")); _requirementType = AddRequirementTypeWith1DefWithoutField(context, "RT", "RD", RequirementTypeIcon.Other, 1); _requirementDefinitionWithoutOneField = _requirementType.RequirementDefinitions.Single(); _infoField = AddInfoField(context, _requirementDefinitionWithoutOneField, "I"); // be sure to use different intervals in the TagRequirement and RequirementDefinition to be able to Assert on correct value for dto.IntervalWeeks _interval = _requirementDefinitionWithoutOneField.DefaultIntervalWeeks * 2; var requirementWithoutField = new TagRequirement(TestPlant, _interval, _requirementDefinitionWithoutOneField); var tag = new Tag(TestPlant, TagType.Standard, "TagNo", "Description", journey.Steps.ElementAt(0), new List <TagRequirement> { requirementWithoutField }); context.Tags.Add(tag); Assert.IsNull(requirementWithoutField.ActivePeriod); // All TagRequirements get an active Period when starting tag.StartPreservation(); Assert.IsNotNull(requirementWithoutField.ActivePeriod); context.SaveChangesAsync().Wait(); _tagId = tag.Id; _requirementWithoutFieldId = requirementWithoutField.Id; var activePeriodForRequirementWithOutField = tag.Requirements.Single(r => r.Id == requirementWithoutField.Id).ActivePeriod; Assert.IsNull(activePeriodForRequirementWithOutField.PreservationRecord); requirementWithoutField.SetComment(_comment); // Active Period gets a Preservation Record and the current Active Period be a new active Period when preserving tag.Preserve(new Mock <Person>().Object, _requirementWithoutFieldId); Assert.IsNotNull(activePeriodForRequirementWithOutField.PreservationRecord); context.SaveChangesAsync().Wait(); _preservationRecordGuid = activePeriodForRequirementWithOutField.PreservationRecord.ObjectGuid; _preservationRecordId = activePeriodForRequirementWithOutField.PreservationRecord.Id; } }
public void Setup() { var mode = new Mode(TestPlant, "SUP", true); mode.SetProtectedIdForTesting(ModeId); var step = new Step(TestPlant, "SUP", mode, new Responsible(TestPlant, "C", "D")); step.SetProtectedIdForTesting(StepId); var rdMock = new Mock <RequirementDefinition>(); rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); _req1OnTag1WithTwoWeekInterval = new TagRequirement(TestPlant, TwoWeeksInterval, rdMock.Object); _req2OnTag1WithFourWeekInterval = new TagRequirement(TestPlant, FourWeeksInterval, rdMock.Object); _req1OnTag2WithTwoWeekInterval = new TagRequirement(TestPlant, TwoWeeksInterval, rdMock.Object); _req2OnTag2WithFourWeekInterval = new TagRequirement(TestPlant, FourWeeksInterval, rdMock.Object); _tag1 = new Tag(TestPlant, TagType.Standard, "", "", step, new List <TagRequirement> { _req1OnTag1WithTwoWeekInterval, _req2OnTag1WithFourWeekInterval }); _tag2 = new Tag(TestPlant, TagType.Standard, "", "", step, new List <TagRequirement> { _req1OnTag2WithTwoWeekInterval, _req2OnTag2WithFourWeekInterval }); var tags = new List <Tag> { _tag1, _tag2 }; var tagIds = new List <int> { TagId1, TagId2 }; _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagsByTagIdsAsync(tagIds)).Returns(Task.FromResult(tags)); _personRepoMock = new Mock <IPersonRepository>(); _personRepoMock .Setup(p => p.GetByOidAsync(It.Is <Guid>(x => x == CurrentUserOid))) .Returns(Task.FromResult(new Person(CurrentUserOid, "Test", "User"))); _command = new BulkPreserveCommand(tagIds); _tag1.StartPreservation(); _tag2.StartPreservation(); _dut = new BulkPreserveCommandHandler( _projectRepoMock.Object, _personRepoMock.Object, UnitOfWorkMock.Object, CurrentUserProviderMock.Object); }
public async Task HandleGetRequirementTypeByIdQuery_AfterPreservationRecorded_ShouldSetFieldInUse() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetRequirementTypeByIdQueryHandler(context); var result = await dut.Handle(new GetRequirementTypeByIdQuery(_requirementType.Id), default); var reqDef = result.Data.RequirementDefinitions.Single(rd => rd.Id == _requirementDefWithCheckbox.Id); Assert.IsFalse(reqDef.Fields.Single().IsInUse); var journey = AddJourneyWithStep(context, "J1", "S", AddMode(context, "M1", false), AddResponsible(context, "R1")); var tagRequirement = new TagRequirement(TestPlant, 2, _requirementDefWithCheckbox); var tag = new Tag(TestPlant, TagType.Standard, "TagNo", "Description", journey.Steps.ElementAt(0), new List <TagRequirement> { tagRequirement }); tag.StartPreservation(); context.Tags.Add(tag); context.SaveChangesAsync().Wait(); tagRequirement.RecordCheckBoxValues( new Dictionary <int, bool> { { _checkboxField.Id, true } }, _requirementDefWithCheckbox); context.SaveChangesAsync().Wait(); } using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetRequirementTypeByIdQueryHandler(context); var result = await dut.Handle(new GetRequirementTypeByIdQuery(_requirementType.Id), default); var reqDef = result.Data.RequirementDefinitions.Single(rd => rd.Id == _requirementDefWithCheckbox.Id); Assert.IsTrue(reqDef.Fields.Single().IsInUse); } }
public static void AddTags(this IEnumerable <Project> projects, int entryCountPrPoject, string plant, List <Step> steps, List <RequirementDefinition> requirementDefinitions) { var rand = new Random(); foreach (var project in projects) { for (var i = 0; i < entryCountPrPoject; i++) { var requirements = new List <TagRequirement>(); for (var j = 0; j < 5; j++) { var requirement = new TagRequirement(plant, 2, requirementDefinitions[rand.Next(requirementDefinitions.Count)]); requirements.Add(requirement); } var tag = new Tag( plant, TagType.Standard, $"TagNo-{i}", "Description", steps[rand.Next(steps.Count)], requirements) { Calloff = "CallOffNo", CommPkgNo = "CommPkgNo", McPkgNo = "McPkgNo", PurchaseOrderNo = "PoNo", Remark = "Remark", StorageArea = "SA", TagFunctionCode = "TFC" }; tag.SetArea("AreaCode", "AreaDescription"); tag.SetDiscipline("DisciplineCode", "DisciplineDescription"); project.AddTag(tag); } } }
public void Setup() { var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); _rd1Mock = new Mock <RequirementDefinition>(); _rd1Mock.SetupGet(rd => rd.Id).Returns(_rdId1); _rd1Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _rd2Mock = new Mock <RequirementDefinition>(); _rd2Mock.SetupGet(rd => rd.Id).Returns(_rdId2); _rd2Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _req1OnTag1 = new TagRequirement(TestPlant, _intervalWeeks, _rd1Mock.Object); _req2OnTag1 = new TagRequirement(TestPlant, _intervalWeeks, _rd2Mock.Object); _req1OnTag2 = new TagRequirement(TestPlant, _intervalWeeks, _rd1Mock.Object); _req2OnTag2 = new TagRequirement(TestPlant, _intervalWeeks, _rd2Mock.Object); _tag1 = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _req1OnTag1, _req2OnTag1 }); _tag2 = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _req1OnTag2, _req2OnTag2 }); var tags = new List <Tag> { _tag1, _tag2 }; var tagIds = new List <int> { _tagId1, _tagId2 }; _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagsByTagIdsAsync(tagIds)).Returns(Task.FromResult(tags)); _command = new StartPreservationCommand(tagIds); _dut = new StartPreservationCommandHandler(_projectRepoMock.Object, UnitOfWorkMock.Object); }
public async Task AnyExcludedFieldsIsInUseAsync_TheExcludedFieldHasRecordedPreservation_ShouldReturnTrue() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var project = AddProject(context, "P", "D"); var tagRequirement = new TagRequirement(TestPlant, 4, _reqDefWithTwoFields); var tag = new Tag(TestPlant, TagType.Standard, "TagNo", "Desc", stepMock.Object, new List <TagRequirement> { tagRequirement }); tag.StartPreservation(); project.AddTag(tag); context.SaveChangesAsync().Wait(); var requirementDefinition = context.RequirementDefinitions.Include(rd => rd.Fields) .Single(rd => rd.Id == _reqDefWithTwoFields.Id); tagRequirement.RecordCheckBoxValues( new Dictionary <int, bool> { { _cbFieldId, true } }, requirementDefinition); context.SaveChangesAsync().Wait(); } using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new RequirementDefinitionValidator(context); var result = await dut.AnyExcludedFieldsIsInUseAsync(_reqDefWithTwoFields.Id, new List <int> { _numberFieldId }, default); Assert.IsTrue(result); } }
public void Setup() { var responsible = new Responsible(TestPlant, "C", "D"); var supplierMode = new Mode(TestPlant, "SUP", true); supplierMode.SetProtectedIdForTesting(SupplierModeId); _supplierStep = new Step(TestPlant, "SUP", supplierMode, responsible); _supplierStep.SetProtectedIdForTesting(SupplierStepId); var otherMode = new Mode(TestPlant, "OTHER", false); otherMode.SetProtectedIdForTesting(OtherModeId); _otherStep = new Step(TestPlant, "OTHER", otherMode, responsible); _otherStep.SetProtectedIdForTesting(OtherStepId); var rdForSupplier = new RequirementDefinition(TestPlant, "ForSupp", Interval, RequirementUsage.ForSuppliersOnly, 1); var rdForOther = new RequirementDefinition(TestPlant, "ForOther", Interval, RequirementUsage.ForOtherThanSuppliers, 2); _requirementForSupplier = new TagRequirement(TestPlant, Interval, rdForSupplier); _requirementForSupplier.SetProtectedIdForTesting(RequirementForSupplierId); _requirementForOther = new TagRequirement(TestPlant, Interval, rdForOther); _requirementForOther.SetProtectedIdForTesting(RequirementForOtherId); _tagInSupplierStep = new Tag(TestPlant, TagType.Standard, "", "", _supplierStep, new List <TagRequirement> { _requirementForSupplier }); _tagInSupplierStep.SetProtectedIdForTesting(TagInSupplierStepId); _tagInOtherStep = new Tag(TestPlant, TagType.Standard, "", "", _otherStep, new List <TagRequirement> { _requirementForOther }); _tagInOtherStep.SetProtectedIdForTesting(TagInOtherStepId); _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(TagInSupplierStepId)).Returns(Task.FromResult(_tagInSupplierStep)); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(TagInOtherStepId)).Returns(Task.FromResult(_tagInOtherStep)); _personRepoMock = new Mock <IPersonRepository>(); _personRepoMock .Setup(p => p.GetByOidAsync(It.Is <Guid>(x => x == CurrentUserOid))) .Returns(Task.FromResult(new Person(CurrentUserOid, "Test", "User"))); _commandForSupplierRequirement = new PreserveCommand(TagInSupplierStepId, RequirementForSupplierId); _commandForOtherRequirement = new PreserveCommand(TagInOtherStepId, RequirementForOtherId); _timeProvider.Elapse(TimeSpan.FromDays(-1)); _tagInSupplierStep.StartPreservation(); _tagInOtherStep.StartPreservation(); _timeProvider.SetTime(_utcNow); _initialPreservationPeriodForSupplierRequirement = _requirementForSupplier.PreservationPeriods.Single(); _initialPreservationPeriodForOtherRequirement = _requirementForOther.PreservationPeriods.Single(); _dut = new PreserveCommandHandler( _projectRepoMock.Object, _personRepoMock.Object, UnitOfWorkMock.Object, CurrentUserProviderMock.Object); }
public RequiredTagConstraint(TagRequirement requirementLevel, DicomTagConstraint constraint) { RequirementLevel = requirementLevel; Constraint = constraint; }
public void Setup() { var _tagId = 1; var _attachmentFieldId = 12; var _reqId = 21; _command = new UploadFieldValueAttachmentCommand( _tagId, _reqId, _attachmentFieldId, _fileName, new MemoryStream()); _requirementDefinition = new Mock <RequirementDefinition>(); _requirementDefinition.SetupGet(r => r.Id).Returns(_reqId); _requirementDefinition.SetupGet(r => r.Plant).Returns(TestPlant); var attachmentFieldMock = new Mock <Field>(TestPlant, "", FieldType.Attachment, 0, "", false); attachmentFieldMock.SetupGet(f => f.Id).Returns(_attachmentFieldId); attachmentFieldMock.SetupGet(f => f.Plant).Returns(TestPlant); _requirementDefinition.Object.AddField(attachmentFieldMock.Object); var requirementMock = new Mock <TagRequirement>(TestPlant, 2, _requirementDefinition.Object); requirementMock.SetupGet(r => r.Id).Returns(_reqId); requirementMock.SetupGet(r => r.Plant).Returns(TestPlant); _requirement = requirementMock.Object; var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var tag = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _requirement }); tag.StartPreservation(); Assert.AreEqual(PreservationStatus.Active, tag.Status); Assert.IsTrue(_requirement.HasActivePeriod); var _projectRepositoryMock = new Mock <IProjectRepository>(); _projectRepositoryMock .Setup(r => r.GetTagByTagIdAsync(_tagId)) .Returns(Task.FromResult(tag)); var _rtRepositoryMock = new Mock <IRequirementTypeRepository>(); _rtRepositoryMock .Setup(r => r.GetRequirementDefinitionByIdAsync(_reqId)) .Returns(Task.FromResult(_requirementDefinition.Object)); _blobStorageMock = new Mock <IBlobStorage>(); var attachmentOptionsMock = new Mock <IOptionsMonitor <AttachmentOptions> >(); var options = new AttachmentOptions { MaxSizeMb = 2, BlobContainer = _blobContainer, ValidFileSuffixes = new[] { ".gif", ".jpg" } }; attachmentOptionsMock .Setup(x => x.CurrentValue) .Returns(options); _dut = new UploadFieldValueAttachmentCommandHandler( _projectRepositoryMock.Object, _rtRepositoryMock.Object, UnitOfWorkMock.Object, PlantProviderMock.Object, _blobStorageMock.Object, attachmentOptionsMock.Object); }
public void Setup() { var modeMock = new Mock <Mode>(); modeMock.SetupGet(x => x.Plant).Returns(TestPlant); var responsibleMock = new Mock <Responsible>(); responsibleMock.SetupGet(x => x.Plant).Returns(TestPlant); var step = new Step(TestPlant, "S", modeMock.Object, responsibleMock.Object); step.SetProtectedIdForTesting(StepId); var rdMock = new Mock <RequirementDefinition>(); rdMock.SetupGet(rd => rd.Plant).Returns(TestPlant); var project1 = new Project(TestPlant, ProjectNameWithTags, "Desc1"); var req1 = new TagRequirement(TestPlant, 1, rdMock.Object); var req2 = new TagRequirement(TestPlant, 2, rdMock.Object); var req3 = new TagRequirement(TestPlant, 4, rdMock.Object); _standardTag1With3Reqs = new Tag(TestPlant, TagType.Standard, StandardTagNo1, "Desc", step, new List <TagRequirement> { req1, req2, req3 }) { CommPkgNo = CommPkg1, McPkgNo = McPkg1 }; _standardTag1With3Reqs.SetProtectedIdForTesting(StandardTagId1); project1.AddTag(_standardTag1With3Reqs); var reqTag2 = new TagRequirement(TestPlant, 1, rdMock.Object); _standardTag2 = new Tag(TestPlant, TagType.Standard, StandardTagNo2, "Desc2", step, new List <TagRequirement> { reqTag2 }) { CommPkgNo = CommPkg2, McPkgNo = McPkg2 }; _standardTag2.SetProtectedIdForTesting(StandardTagId2); project1.AddTag(_standardTag2); var req4 = new TagRequirement(TestPlant, 1, rdMock.Object); var req5 = new TagRequirement(TestPlant, 2, rdMock.Object); var req6 = new TagRequirement(TestPlant, 4, rdMock.Object); var poTag = new Tag(TestPlant, TagType.PoArea, PoTagNo, "Desc", step, new List <TagRequirement> { req4, req5, req6 }); poTag.SetProtectedIdForTesting(PoTagId); project1.AddTag(poTag); var project2 = new Project(TestPlant, ProjectNameWithoutTags, "Desc2"); var projects = new List <Project> { project1, project2 }; var projectsSetMock = projects.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Projects) .Returns(projectsSetMock.Object); var tags = new List <Tag> { _standardTag1With3Reqs, poTag }; _tagsSetMock = tags.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Tags) .Returns(_tagsSetMock.Object); var reqs = new List <TagRequirement> { req1, req2, req3, req4, req5, req6, reqTag2 }; _reqsSetMock = reqs.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.TagRequirements) .Returns(_reqsSetMock.Object); _dut = new ProjectRepository(ContextHelper.ContextMock.Object); }
public void Setup() { var rdId1 = 17; var rdId2 = 18; var tagId1 = 7; var tagId2 = 8; var stepId1 = 9; var stepId2 = 10; var step1Mock = new Mock <Step>(); step1Mock.SetupGet(s => s.Plant).Returns(TestPlant); step1Mock.SetupGet(s => s.Id).Returns(stepId1); var step2Mock = new Mock <Step>(); step2Mock.SetupGet(s => s.Plant).Returns(TestPlant); step2Mock.SetupGet(s => s.Id).Returns(stepId2); var journey = new Journey(TestPlant, "D"); journey.AddStep(step1Mock.Object); journey.AddStep(step2Mock.Object); _rd1Mock = new Mock <RequirementDefinition>(); _rd1Mock.SetupGet(rd => rd.Id).Returns(rdId1); _rd1Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _rd2Mock = new Mock <RequirementDefinition>(); _rd2Mock.SetupGet(rd => rd.Id).Returns(rdId2); _rd2Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _req1OnTag1 = new TagRequirement(TestPlant, 2, _rd1Mock.Object); _req2OnTag1 = new TagRequirement(TestPlant, 2, _rd2Mock.Object); _req1OnTag2 = new TagRequirement(TestPlant, 2, _rd1Mock.Object); _req2OnTag2 = new TagRequirement(TestPlant, 2, _rd2Mock.Object); _tag1 = new Tag(TestPlant, TagType.Standard, "", "", step2Mock.Object, new List <TagRequirement> { _req1OnTag1, _req2OnTag1 }); _tag1.StartPreservation(); _tag1.SetProtectedIdForTesting(tagId1); _tag2 = new Tag(TestPlant, TagType.Standard, "", "", step2Mock.Object, new List <TagRequirement> { _req1OnTag2, _req2OnTag2 }); _tag2.StartPreservation(); _tag2.SetProtectedIdForTesting(tagId2); var tags = new List <Tag> { _tag1, _tag2 }; var tagIds = new List <int> { tagId1, tagId2 }; var tagIdsWithRowVersion = new List <IdAndRowVersion> { new IdAndRowVersion(tagId1, _rowVersion1), new IdAndRowVersion(tagId2, _rowVersion2) }; _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagsByTagIdsAsync(tagIds)).Returns(Task.FromResult(tags)); var journeyRepoMock = new Mock <IJourneyRepository>(); journeyRepoMock .Setup(r => r.GetJourneysByStepIdsAsync(new List <int> { stepId2 })) .Returns(Task.FromResult(new List <Journey> { journey })); _command = new CompletePreservationCommand(tagIdsWithRowVersion); _dut = new CompletePreservationCommandHandler(_projectRepoMock.Object, journeyRepoMock.Object, UnitOfWorkMock.Object); }
public void Setup() { var _tagId = 1; var _checkBoxFieldId = 11; var _numberFieldId = 12; var _reqId = 21; _recordValuesCommandWithCheckedCheckBoxAndNumber = new RecordValuesCommand( _tagId, _reqId, new List <NumberFieldValue> { new NumberFieldValue(_numberFieldId, 21, false) }, new List <CheckBoxFieldValue> { new CheckBoxFieldValue(_checkBoxFieldId, true) }, null); _recordValuesCommandWithNullAsNumber = new RecordValuesCommand( _tagId, _reqId, new List <NumberFieldValue> { new NumberFieldValue(_numberFieldId, null, false) }, null, null); var requirementDefinitionWith2FieldsMock = new Mock <RequirementDefinition>(); requirementDefinitionWith2FieldsMock.SetupGet(r => r.Id).Returns(_reqId); requirementDefinitionWith2FieldsMock.SetupGet(r => r.Plant).Returns(TestPlant); var checkBoxFieldMock = new Mock <Field>(TestPlant, "", FieldType.CheckBox, 0, null, null); checkBoxFieldMock.SetupGet(f => f.Id).Returns(_checkBoxFieldId); checkBoxFieldMock.SetupGet(f => f.Plant).Returns(TestPlant); requirementDefinitionWith2FieldsMock.Object.AddField(checkBoxFieldMock.Object); var numberFieldMock = new Mock <Field>(TestPlant, "", FieldType.Number, 0, "mm", false); numberFieldMock.SetupGet(f => f.Id).Returns(_numberFieldId); numberFieldMock.SetupGet(f => f.Plant).Returns(TestPlant); requirementDefinitionWith2FieldsMock.Object.AddField(numberFieldMock.Object); var requirementMock = new Mock <TagRequirement>(TestPlant, 2, requirementDefinitionWith2FieldsMock.Object); requirementMock.SetupGet(r => r.Id).Returns(_reqId); requirementMock.SetupGet(r => r.Plant).Returns(TestPlant); _requirement = requirementMock.Object; var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); var tag = new Tag(TestPlant, TagType.Standard, "", "", stepMock.Object, new List <TagRequirement> { _requirement }); tag.StartPreservation(); Assert.AreEqual(PreservationStatus.Active, tag.Status); Assert.IsTrue(_requirement.HasActivePeriod); var _projectRepositoryMock = new Mock <IProjectRepository>(); _projectRepositoryMock .Setup(r => r.GetTagByTagIdAsync(_tagId)) .Returns(Task.FromResult(tag)); var _rtRepositoryMock = new Mock <IRequirementTypeRepository>(); _rtRepositoryMock .Setup(r => r.GetRequirementDefinitionByIdAsync(_reqId)) .Returns(Task.FromResult(requirementDefinitionWith2FieldsMock.Object)); _dut = new RecordValuesCommandHandler( _projectRepositoryMock.Object, _rtRepositoryMock.Object, UnitOfWorkMock.Object); }
public void Setup() { // Arrange _stepMock1 = new Mock <Step>(); _stepMock1.SetupGet(s => s.Id).Returns(StepId1); _stepMock1.SetupGet(s => s.Plant).Returns(TestPlant); _stepMock2 = new Mock <Step>(); _stepMock2.SetupGet(s => s.Id).Returns(StepId2); _stepMock2.SetupGet(s => s.Plant).Returns(TestPlant); _rtRepositoryMock = new Mock <IRequirementTypeRepository>(); var rdMock1 = new Mock <RequirementDefinition>(); rdMock1.SetupGet(x => x.Id).Returns(ReqDefId1); rdMock1.SetupGet(x => x.Plant).Returns(TestPlant); var rdMock2 = new Mock <RequirementDefinition>(); rdMock2.SetupGet(x => x.Id).Returns(ReqDefId2); rdMock2.SetupGet(x => x.Plant).Returns(TestPlant); _rtRepositoryMock .Setup(r => r.GetRequirementDefinitionByIdAsync(ReqDefId2)) .Returns(Task.FromResult(rdMock2.Object)); var reqId = 111; _tagRequirement1OnStandardTag1 = new TagRequirement(TestPlant, ThreeWeekInterval, rdMock1.Object); _tagRequirement1OnStandardTag1.SetProtectedIdForTesting(++reqId); _standardTagWithOneRequirement = new Tag(TestPlant, TagType.Standard, "T1", Description, _stepMock1.Object, new List <TagRequirement> { _tagRequirement1OnStandardTag1 }); _tagRequirement1OnStandardTag2 = new TagRequirement(TestPlant, TwoWeekInterval, rdMock1.Object); _tagRequirement1OnStandardTag2.SetProtectedIdForTesting(++reqId); _tagRequirement2OnStandardTag2 = new TagRequirement(TestPlant, ThreeWeekInterval, rdMock2.Object); _tagRequirement2OnStandardTag2.SetProtectedIdForTesting(++reqId); _standardTagWithTwoRequirements = new Tag(TestPlant, TagType.Standard, "T2", "D", _stepMock1.Object, new List <TagRequirement> { _tagRequirement1OnStandardTag2, _tagRequirement2OnStandardTag2 }); _tagRequirement1OnAreaTag = new TagRequirement(TestPlant, ThreeWeekInterval, rdMock1.Object); _tagRequirement1OnAreaTag.SetProtectedIdForTesting(++reqId); _areaTagWithOneRequirement = new Tag(TestPlant, TagType.PoArea, "T3", Description, _stepMock1.Object, new List <TagRequirement> { _tagRequirement1OnAreaTag }); _journeyRepositoryMock = new Mock <IJourneyRepository>(); _journeyRepositoryMock .Setup(x => x.GetStepByStepIdAsync(StepId1)) .Returns(Task.FromResult(_stepMock1.Object)); _journeyRepositoryMock .Setup(x => x.GetStepByStepIdAsync(StepId2)) .Returns(Task.FromResult(_stepMock2.Object)); _projectRepositoryMock = new Mock <IProjectRepository>(); _projectRepositoryMock.Setup(p => p.GetTagByTagIdAsync(StandardTagId1)).Returns(Task.FromResult(_standardTagWithOneRequirement)); _projectRepositoryMock.Setup(p => p.GetTagByTagIdAsync(StandardTagId2)).Returns(Task.FromResult(_standardTagWithTwoRequirements)); _projectRepositoryMock.Setup(p => p.GetTagByTagIdAsync(AreaTagId)).Returns(Task.FromResult(_areaTagWithOneRequirement)); _dut = new UpdateTagStepAndRequirementsCommandHandler( _projectRepositoryMock.Object, _journeyRepositoryMock.Object, _rtRepositoryMock.Object, UnitOfWorkMock.Object, PlantProviderMock.Object); Assert.AreEqual(1, _standardTagWithOneRequirement.Requirements.Count); }
private static void RecordNumberIsNaValues(List <NumberFieldValue> values, TagRequirement requirement, RequirementDefinition requirementDefinition) { IList <int> fieldIds = values.Where(nv => nv.IsNa).Select(nv => nv.FieldId).ToList(); requirement.RecordNumberIsNaValues(fieldIds, requirementDefinition); }
public void Setup() { var stepMock = new Mock <Step>(); stepMock.SetupGet(s => s.Plant).Returns(TestPlant); stepMock.SetupGet(s => s.Id).Returns(_stepId); _journeyRepositoryMock = new Mock <IJourneyRepository>(); _journeyRepositoryMock .Setup(x => x.GetStepByStepIdAsync(_stepId)) .Returns(Task.FromResult(stepMock.Object)); _rd1Mock = new Mock <RequirementDefinition>(); _rd1Mock.SetupGet(rd => rd.Id).Returns(_rdId1); _rd1Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _rd2Mock = new Mock <RequirementDefinition>(); _rd2Mock.SetupGet(rd => rd.Id).Returns(_rdId2); _rd2Mock.SetupGet(rd => rd.Plant).Returns(TestPlant); _rtRepositoryMock = new Mock <IRequirementTypeRepository>(); _rtRepositoryMock .Setup(r => r.GetRequirementDefinitionsByIdsAsync(new List <int> { _rdId1, _rdId2 })) .Returns(Task.FromResult(new List <RequirementDefinition> { _rd1Mock.Object, _rd2Mock.Object })); _req1 = new TagRequirement(TestPlant, _interval1, _rd1Mock.Object); _req2 = new TagRequirement(TestPlant, _interval2, _rd2Mock.Object); _project = new Project(TestPlant, "TestProjectName", ""); _sourceTag = new Tag( TestPlant, TagType.SiteArea, "TagNo", "Desc", stepMock.Object, new List <TagRequirement> { _req1, _req2 }); _sourceTag.SetArea("AC", "AD"); _sourceTag.SetDiscipline("DC", "DD"); _sourceTag.SetProtectedIdForTesting(_sourceTagId); _project.AddTag(_sourceTag); _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(_sourceTagId)).Returns(Task.FromResult(_sourceTag)); _projectRepoMock .Setup(r => r.GetProjectOnlyByTagIdAsync(_sourceTagId)).Returns(Task.FromResult(_project)); var disciplineCode = "D"; _disciplineApiServiceMock = new Mock <IDisciplineApiService>(); _disciplineApiServiceMock.Setup(s => s.TryGetDisciplineAsync(TestPlant, disciplineCode)) .Returns(Task.FromResult(new PCSDiscipline { Code = disciplineCode, Description = _disciplineDescription })); var areaCode = "A"; _areaApiServiceMock = new Mock <IAreaApiService>(); _areaApiServiceMock.Setup(s => s.TryGetAreaAsync(TestPlant, areaCode)) .Returns(Task.FromResult(new PCSArea { Code = areaCode, Description = _areaDescription })); _command = new DuplicateAreaTagCommand(_sourceTagId, TagType.SiteArea, disciplineCode, areaCode, "-01", "Desc", "Rem", "SA"); _dut = new DuplicateAreaTagCommandHandler( _projectRepoMock.Object, _journeyRepositoryMock.Object, _rtRepositoryMock.Object, UnitOfWorkMock.Object, PlantProviderMock.Object, _disciplineApiServiceMock.Object, _areaApiServiceMock.Object); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var journey = AddJourneyWithStep(context, "J1", "S", AddMode(context, "M1", false), AddResponsible(context, "R1")); var requirementType1 = new RequirementType(TestPlant, _requirementType1Code, _requirementType1Title, _requirementType1Icon, 0); context.RequirementTypes.Add(requirementType1); var requirementType2 = new RequirementType(TestPlant, _requirementType2Code, _requirementType2Title, _requirementType2Icon, 0); context.RequirementTypes.Add(requirementType2); context.SaveChangesAsync().Wait(); var requirementDefinitionWithoutField = new RequirementDefinition(TestPlant, _requirementDefinitionWithoutFieldTitle, 2, RequirementUsage.ForAll, 1); requirementType1.AddRequirementDefinition(requirementDefinitionWithoutField); var requirementDefinitionWithOneInfo = new RequirementDefinition(TestPlant, _requirementDefinitionWithOneInfoTitle, 2, RequirementUsage.ForAll, 1); var infoField = new Field(TestPlant, "Label for Info", FieldType.Info, 0); requirementDefinitionWithOneInfo.AddField(infoField); requirementType1.AddRequirementDefinition(requirementDefinitionWithOneInfo); var requirementDefinitionWithOneAttachment = new RequirementDefinition(TestPlant, _requirementDefinitionWithOneAttachmentTitle, 2, RequirementUsage.ForAll, 1); var attachmentField = new Field(TestPlant, "Label for Attachment", FieldType.Attachment, 0); requirementDefinitionWithOneAttachment.AddField(attachmentField); requirementType1.AddRequirementDefinition(requirementDefinitionWithOneAttachment); var requirementDefinitionWithTwoCheckBoxes = new RequirementDefinition(TestPlant, _requirementDefinitionWithTwoCheckBoxesTitle, 2, RequirementUsage.ForAll, 1); var cbField1 = new Field(TestPlant, "Label for checkBox - second", FieldType.CheckBox, 10); var cbField2 = new Field(TestPlant, "Label for checkBox - first", FieldType.CheckBox, 2); requirementDefinitionWithTwoCheckBoxes.AddField(cbField1); requirementDefinitionWithTwoCheckBoxes.AddField(cbField2); requirementType2.AddRequirementDefinition(requirementDefinitionWithTwoCheckBoxes); var requirementDefinitionWithThreeNumberShowPrev = new RequirementDefinition(TestPlant, _requirementDefinitionWithThreeNumberShowPrevTitle, 2, RequirementUsage.ForAll, 1); var numberFieldPrev1 = new Field(TestPlant, "Label for number - third", FieldType.Number, 15, _unit, true); var numberFieldPrev2 = new Field(TestPlant, "Label for number - first", FieldType.Number, 2, _unit, true); var numberFieldPrev3 = new Field(TestPlant, "Label for number - second", FieldType.Number, 10, _unit, true); requirementDefinitionWithThreeNumberShowPrev.AddField(numberFieldPrev1); requirementDefinitionWithThreeNumberShowPrev.AddField(numberFieldPrev2); requirementDefinitionWithThreeNumberShowPrev.AddField(numberFieldPrev3); requirementType2.AddRequirementDefinition(requirementDefinitionWithThreeNumberShowPrev); var requirementDefinitionWithOneNumberNoPrev = new RequirementDefinition(TestPlant, _requirementDefinitionWithOneNumberNoPrevTitle, 2, RequirementUsage.ForAll, 1); var numberFieldNoPrev = new Field(TestPlant, "Label for number", FieldType.Number, 10, _unit, false); requirementDefinitionWithOneNumberNoPrev.AddField(numberFieldNoPrev); requirementType2.AddRequirementDefinition(requirementDefinitionWithOneNumberNoPrev); var requirementDefinitionForVoidedTest = new RequirementDefinition(TestPlant, _requirementDefinitionForVoidedTest, 2, RequirementUsage.ForAll, 1); var vField1 = new Field(TestPlant, "Label for field", FieldType.CheckBox, 10); requirementDefinitionForVoidedTest.AddField(vField1); requirementType2.AddRequirementDefinition(requirementDefinitionForVoidedTest); context.SaveChangesAsync().Wait(); var requirementWithoutField = new TagRequirement(TestPlant, _interval, requirementDefinitionWithoutField); var requirementWithOneInfo = new TagRequirement(TestPlant, _interval, requirementDefinitionWithOneInfo); var requirementWithOneAttachment = new TagRequirement(TestPlant, _interval, requirementDefinitionWithOneAttachment); var requirementWithTwoCheckBoxes = new TagRequirement(TestPlant, _interval, requirementDefinitionWithTwoCheckBoxes); var requirementWithOneNumberNoPrev = new TagRequirement(TestPlant, _interval, requirementDefinitionWithOneNumberNoPrev); var requirementWithThreeNumberShowPrev = new TagRequirement(TestPlant, _interval, requirementDefinitionWithThreeNumberShowPrev); var requirementThatIsVoided = new TagRequirement(TestPlant, _interval, requirementDefinitionForVoidedTest); requirementThatIsVoided.IsVoided = true; var tag = new Tag(TestPlant, TagType.Standard, "TagNo", "Description", journey.Steps.ElementAt(0), new List <TagRequirement> { requirementWithoutField, requirementWithOneInfo, requirementWithOneAttachment, requirementWithTwoCheckBoxes, requirementWithOneNumberNoPrev, requirementWithThreeNumberShowPrev, requirementThatIsVoided }); context.Tags.Add(tag); context.SaveChangesAsync().Wait(); _tagId = tag.Id; _requirementDefinitionWithOneAttachmentId = requirementDefinitionWithOneAttachment.Id; _requirementDefinitionWithTwoCheckBoxesId = requirementDefinitionWithTwoCheckBoxes.Id; _requirementDefinitionWithThreeNumberShowPrevId = requirementDefinitionWithThreeNumberShowPrev.Id; _requirementWithoutFieldId = requirementWithoutField.Id; _requirementWithOneInfoId = requirementWithOneInfo.Id; _requirementWithOneAttachmentId = requirementWithOneAttachment.Id; _requirementWithTwoCheckBoxesId = requirementWithTwoCheckBoxes.Id; _requirementWithThreeNumberShowPrevId = requirementWithThreeNumberShowPrev.Id; _requirementWithOneNumberNoPrevId = requirementWithOneNumberNoPrev.Id; _attachmentFieldId = attachmentField.Id; _firstCbFieldId = cbField2.Id; _secondCbFieldId = cbField1.Id; _firstNumberFieldId = numberFieldPrev2.Id; _secondNumberFieldId = numberFieldPrev3.Id; _thirdNumberFieldId = numberFieldPrev1.Id; } }
public void Setup() { var supplierMode = new Mode(TestPlant, "SUP", true); supplierMode.SetProtectedIdForTesting(SupplierModeId); var otherMode = new Mode(TestPlant, "HOOKUP", false); otherMode.SetProtectedIdForTesting(OtherModeId); var responsible = new Responsible(TestPlant, "C", "D"); var supplierStep = new Step(TestPlant, "SUP", supplierMode, responsible); supplierStep.SetProtectedIdForTesting(SupplierStepId); var otherStep = new Step(TestPlant, "HOOKUP", otherMode, responsible); otherStep.SetProtectedIdForTesting(OtherStepId); var rdForAllTwoWeekInterval = new RequirementDefinition(TestPlant, "ForAll", TwoWeeksInterval, RequirementUsage.ForAll, 1); var rdForSupplierTwoWeekInterval = new RequirementDefinition(TestPlant, "ForSup", TwoWeeksInterval, RequirementUsage.ForSuppliersOnly, 2); var rdForOtherTwoWeekInterval = new RequirementDefinition(TestPlant, "ForOther", TwoWeeksInterval, RequirementUsage.ForOtherThanSuppliers, 3); _req1ForAllWithTwoWeekInterval = new TagRequirement(TestPlant, TwoWeeksInterval, rdForAllTwoWeekInterval); _req2ForAllWithTwoWeekInterval = new TagRequirement(TestPlant, TwoWeeksInterval, rdForAllTwoWeekInterval); _req3ForAllWithFourWeekInterval = new TagRequirement(TestPlant, FourWeeksInterval, rdForAllTwoWeekInterval); _tagWithForAllRequirements = new Tag(TestPlant, TagType.Standard, "", "", supplierStep, new List <TagRequirement> { _req1ForAllWithTwoWeekInterval, _req2ForAllWithTwoWeekInterval, _req3ForAllWithFourWeekInterval }); _reqForSupplierInSupplierStep = new TagRequirement(TestPlant, TwoWeeksInterval, rdForSupplierTwoWeekInterval); _reqForOtherInSupplierStep = new TagRequirement(TestPlant, TwoWeeksInterval, rdForOtherTwoWeekInterval); _tagWithSupplierAndOtherRequirementsInSupplierStep = new Tag(TestPlant, TagType.Standard, "", "", supplierStep, new List <TagRequirement> { _reqForSupplierInSupplierStep, _reqForOtherInSupplierStep }); _reqForSupplierInOtherStep = new TagRequirement(TestPlant, TwoWeeksInterval, rdForSupplierTwoWeekInterval); _reqForOtherInOtherStep = new TagRequirement(TestPlant, TwoWeeksInterval, rdForOtherTwoWeekInterval); _tagWithSupplierAndOtherRequirementsInOtherStep = new Tag(TestPlant, TagType.Standard, "", "", otherStep, new List <TagRequirement> { _reqForSupplierInOtherStep, _reqForOtherInOtherStep }); _projectRepoMock = new Mock <IProjectRepository>(); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(TagWithForAllRequirementsId)).Returns(Task.FromResult(_tagWithForAllRequirements)); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(TagInOtherStepId)).Returns(Task.FromResult(_tagWithSupplierAndOtherRequirementsInOtherStep)); _projectRepoMock.Setup(r => r.GetTagByTagIdAsync(TagInSupplierStepId)).Returns(Task.FromResult(_tagWithSupplierAndOtherRequirementsInSupplierStep)); _personRepoMock = new Mock <IPersonRepository>(); _personRepoMock .Setup(p => p.GetByOidAsync(It.Is <Guid>(x => x == CurrentUserOid))) .Returns(Task.FromResult(new Person(CurrentUserOid, "Test", "User"))); _commandForTagWithForAllRequirements = new PreserveCommand(TagWithForAllRequirementsId); _commandForTagInOtherStep = new PreserveCommand(TagInOtherStepId); _commandForTagInSupplierStep = new PreserveCommand(TagInSupplierStepId); _tagWithForAllRequirements.StartPreservation(); _tagWithSupplierAndOtherRequirementsInOtherStep.StartPreservation(); _tagWithSupplierAndOtherRequirementsInSupplierStep.StartPreservation(); _dut = new PreserveCommandHandler( _projectRepoMock.Object, _personRepoMock.Object, UnitOfWorkMock.Object, CurrentUserProviderMock.Object); }