Ejemplo n.º 1
0
        public void Update_ShouldUpdateMarkOperatingConditions()
        {
            // Arrange
            int markId = 1;
            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 markOperatingConditionsRequest = new MarkOperatingConditionsUpdateRequest
            {
                SafetyCoeff            = 2.0f,
                Temperature            = -40,
                EnvAggressivenessId    = envAggressivenessId,
                OperatingAreaId        = operatingAreaId,
                GasGroupId             = gasGroupId,
                ConstructionMaterialId = constructionMaterialId,
                PaintworkTypeId        = paintworkTypeId,
                HighTensileBoltsTypeId = highTensileBoltsTypeId,
            };

            // Act
            _service.Update(markId,
                            markOperatingConditionsRequest);

            // Assert
            _repository.Verify(mock => mock.Update(It.IsAny <MarkOperatingConditions>()), Times.Once);
            Assert.Equal(envAggressivenessId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).EnvAggressiveness.Id);
            Assert.Equal(operatingAreaId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).OperatingArea.Id);
            Assert.Equal(gasGroupId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).GasGroup.Id);
            Assert.Equal(constructionMaterialId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).ConstructionMaterial.Id);
            Assert.Equal(paintworkTypeId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).PaintworkType.Id);
            Assert.Equal(highTensileBoltsTypeId, _markOperatingConditions.SingleOrDefault(
                             v => v.Mark.Id == markId).HighTensileBoltsType.Id);
        }
Ejemplo n.º 2
0
 public ActionResult Update(
     int markId,
     [FromBody] MarkOperatingConditionsUpdateRequest markOperatingConditionsRequest)
 {
     if (!markOperatingConditionsRequest.Validate())
     {
         return(BadRequest());
     }
     try
     {
         _service.Update(markId, markOperatingConditionsRequest);
     }
     catch (ArgumentNullException)
     {
         return(NotFound());
     }
     return(NoContent());
 }