예제 #1
0
        public void Create_ShouldCreateMarkOperatingConditions()
        {
            // Arrange
            int markId = 3;
            int envAggressivenessId    = _rnd.Next(1, TestData.envAggressiveness.Count());
            int operatingAreaId        = _rnd.Next(1, TestData.operatingAreas.Count());
            int gasGroupId             = _rnd.Next(1, TestData.gasGroups.Count());
            int constructionMaterialId = _rnd.Next(1, TestData.constructionMaterials.Count());
            int paintworkTypeId        = _rnd.Next(1, TestData.paintworkTypes.Count());
            int highTensileBoltsTypeId = _rnd.Next(1, TestData.highTensileBoltsTypes.Count());

            var newMarkOperatingConditions = new MarkOperatingConditions
            {
                SafetyCoeff = 1.0f,
                Temperature = -34,
            };

            // Act
            _service.Create(newMarkOperatingConditions,
                            markId,
                            envAggressivenessId,
                            operatingAreaId,
                            gasGroupId,
                            constructionMaterialId,
                            paintworkTypeId,
                            highTensileBoltsTypeId);

            // Assert
            _repository.Verify(mock => mock.Add(
                                   It.IsAny <MarkOperatingConditions>()), Times.Once);
            Assert.NotNull(newMarkOperatingConditions.Mark);
        }
예제 #2
0
        public ActionResult Create(
            int markId,
            [FromBody] MarkOperatingConditionsCreateRequest markOperatingConditionsRequest)
        {
            var markOperatingConditionsModel = _mapper.Map <MarkOperatingConditions>(
                markOperatingConditionsRequest);

            try
            {
                _service.Create(
                    markOperatingConditionsModel,
                    markId,
                    markOperatingConditionsRequest.EnvAggressivenessId,
                    markOperatingConditionsRequest.OperatingAreaId,
                    markOperatingConditionsRequest.GasGroupId,
                    markOperatingConditionsRequest.ConstructionMaterialId,
                    markOperatingConditionsRequest.PaintworkTypeId,
                    markOperatingConditionsRequest.HighTensileBoltsTypeId);
            }
            catch (ArgumentNullException)
            {
                return(NotFound());
            }
            catch (ConflictException)
            {
                return(Conflict());
            }
            return(Created(
                       $"marks/{markId}/mark-operating-conditions", null));
        }