public void Setup()
        {
            // Arrange
            var requirementTypeId     = 1;
            var reqTypeRepositoryMock = new Mock <IRequirementTypeRepository>();

            _requirementType = new RequirementType(TestPlant, "TestCode", "RequirementTypeTitle", _reqIconOther, 10);
            _requirementType.SetProtectedIdForTesting(requirementTypeId);

            reqTypeRepositoryMock.Setup(m => m.GetByIdAsync(requirementTypeId))
            .Returns(Task.FromResult(_requirementType));

            _command = new VoidRequirementTypeCommand(requirementTypeId, _rowVersion);

            _dut = new VoidRequirementTypeCommandHandler(
                reqTypeRepositoryMock.Object,
                UnitOfWorkMock.Object);
        }
        public void Setup()
        {
            // Arrange
            var reqTypeRepositoryMock   = new Mock <IRequirementTypeRepository>();
            var requirementTypeId       = 1;
            var requirementDefinitionId = 2;
            var requirementType         = new RequirementType(TestPlant, "TestCode", "ReqTypeTitle", RequirementTypeIcon.Other, 99);

            requirementType.SetProtectedIdForTesting(requirementTypeId);

            _requirementDefinition = new RequirementDefinition(TestPlant, "ReqDefinitionTitle", 4, RequirementUsage.ForAll, 88);
            _requirementDefinition.SetProtectedIdForTesting(requirementDefinitionId);
            _requirementDefinition.IsVoided = true;

            requirementType.AddRequirementDefinition(_requirementDefinition);
            reqTypeRepositoryMock.Setup(m => m.GetByIdAsync(requirementTypeId))
            .Returns(Task.FromResult(requirementType));

            _command = new UnvoidRequirementDefinitionCommand(requirementTypeId, requirementDefinitionId, _rowVersion);
            _dut     = new UnvoidRequirementDefinitionCommandHandler(
                reqTypeRepositoryMock.Object,
                UnitOfWorkMock.Object);
        }
Esempio n. 3
0
        public void Setup()
        {
            // Arrange
            var requirementTypeId       = 1;
            var requirementDefinitionId = 2;

            _fieldId = 3;

            var requirementTypeRepositoryMock = new Mock <IRequirementTypeRepository>();

            _requirementType = new RequirementType(TestPlant, "Req type code", "Req type title", RequirementTypeIcon.Other, 10);
            _requirementType.SetProtectedIdForTesting(requirementTypeId);

            _requirementDefinition = new RequirementDefinition(TestPlant, _oldTitle, _oldDefaultWeeks, _oldUsage, _oldSortKey);
            _requirementDefinition.SetProtectedIdForTesting(requirementDefinitionId);

            _field = new Field(TestPlant, _oldLabel, _oldFieldType, _oldSortKey, _oldUnit, _oldShowPrevious);
            _field.SetProtectedIdForTesting(_fieldId);

            _requirementDefinition.AddField(_field);
            _requirementType.AddRequirementDefinition(_requirementDefinition);

            requirementTypeRepositoryMock.Setup(j => j.GetByIdAsync(requirementTypeId))
            .Returns(Task.FromResult(_requirementType));

            _updateCommandWithUpdateField = new UpdateRequirementDefinitionCommand(
                requirementTypeId,
                requirementDefinitionId,
                _newSortKey1,
                _newUsage,
                _newTitle,
                _newDefaultWeeks,
                _rowVersion,
                new List <UpdateFieldsForCommand>
            {
                new UpdateFieldsForCommand(_fieldId, _newLabel1, FieldType.Number, _newSortKey1, true, _rowVersion, _newUnit1, _newShowPrevious1)
            },
                new List <FieldsForCommand>()
                );
            _updateCommandWithDeleteField = new UpdateRequirementDefinitionCommand(
                requirementTypeId,
                requirementDefinitionId,
                _newSortKey1,
                _newUsage,
                _newTitle,
                _newDefaultWeeks,
                _rowVersion,
                new List <UpdateFieldsForCommand>(),
                new List <FieldsForCommand>()
                );
            _updateCommandWithUpdateAndAddField = new UpdateRequirementDefinitionCommand(
                requirementTypeId,
                requirementDefinitionId,
                _newSortKey1,
                _newUsage,
                _newTitle,
                _newDefaultWeeks,
                _rowVersion,
                new List <UpdateFieldsForCommand>
            {
                new UpdateFieldsForCommand(_fieldId, _newLabel1, FieldType.Number, _newSortKey1, true, _rowVersion, _newUnit1, _newShowPrevious1)
            },
                new List <FieldsForCommand>
            {
                new FieldsForCommand(_newLabel2, _newFieldType2, _newSortKey2, _newUnit2, _newShowPrevious2)
            }
                );

            _dut = new UpdateRequirementDefinitionCommandHandler(
                requirementTypeRepositoryMock.Object,
                UnitOfWorkMock.Object,
                PlantProviderMock.Object);
        }