public void Update_ShouldUpdateConstruction()
        {
            // Arrange
            int   id             = _rnd.Next(1, _updateConstructions.Count());
            var   newStringValue = "NewUpdate";
            var   newBoolValue   = true;
            short newIntValue    = 99;

            var newConstructionRequest = new ConstructionUpdateRequest
            {
                Name      = newStringValue,
                Valuation = newStringValue,
                NumOfStandardConstructions = newIntValue,
                HasEdgeBlunting            = newBoolValue,
                HasDynamicLoad             = newBoolValue,
                HasFlangedConnections      = newBoolValue,
                PaintworkCoeff             = newIntValue,
            };

            // Act
            _updateService.Update(id, newConstructionRequest);

            // Assert
            _updateRepository.Verify(mock => mock.Update(It.IsAny <Construction>()), Times.Once);
            Assert.Equal(
                newStringValue, _updateConstructions.SingleOrDefault(v => v.Id == id).Name);
            Assert.Equal(
                newStringValue, _updateConstructions.SingleOrDefault(v => v.Id == id).Valuation);
            Assert.Equal(
                newIntValue, _updateConstructions.SingleOrDefault(v => v.Id == id).NumOfStandardConstructions);
            Assert.Equal(
                newBoolValue, _updateConstructions.SingleOrDefault(v => v.Id == id).HasEdgeBlunting);
            Assert.Equal(
                newBoolValue, _updateConstructions.SingleOrDefault(v => v.Id == id).HasDynamicLoad);
            Assert.Equal(
                newBoolValue, _updateConstructions.SingleOrDefault(v => v.Id == id).HasFlangedConnections);
            Assert.Equal(
                newIntValue, _updateConstructions.SingleOrDefault(v => v.Id == id).PaintworkCoeff);
        }
Esempio n. 2
0
 public ActionResult Update(
     int id, [FromBody] ConstructionUpdateRequest constructionRequest)
 {
     if (!constructionRequest.Validate())
     {
         return(BadRequest());
     }
     try
     {
         _service.Update(id, constructionRequest);
     }
     catch (ArgumentNullException)
     {
         return(NotFound());
     }
     catch (ConflictException)
     {
         return(Conflict());
     }
     return(NoContent());
 }