public void Setup_OkState()
        {
            _projectValidatorMock = new Mock <IProjectValidator>();
            _tagValidatorMock     = new Mock <ITagValidator>();
            _tagValidatorMock.Setup(r => r.ExistsRequirementAsync(TagId, ReqId, default)).Returns(Task.FromResult(true));
            _tagValidatorMock.Setup(r => r.HasANonVoidedRequirementAsync(TagId, default)).Returns(Task.FromResult(true));
            _tagValidatorMock.Setup(r => r.VerifyPreservationStatusAsync(TagId, PreservationStatus.Active, default)).Returns(Task.FromResult(true));
            _tagValidatorMock.Setup(r => r.RequirementIsReadyToBePreservedAsync(TagId, ReqId, default)).Returns(Task.FromResult(true));
            _command = new PreserveCommand(TagId, ReqId);

            _dut = new PreserveCommandValidator(_projectValidatorMock.Object, _tagValidatorMock.Object);
        }
        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 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);
        }
Ejemplo n.º 4
0
        public void Constructor_ShouldSetProperties()
        {
            var dut = new PreserveCommand(17);

            Assert.AreEqual(17, dut.TagId);
        }