public void Create_ShouldCreateConstructionElement() { // Arrange int constructionId = _rnd.Next(1, _marks.Count()); int profileId = _rnd.Next(1, _profiles.Count()); int steelId = _rnd.Next(1, _steel.Count()); var newConstructionElement = new ConstructionElement { Length = 1.0f, }; // Act _service.Create( newConstructionElement, constructionId, profileId, steelId); // Assert _repository.Verify(mock => mock.Add( It.IsAny <ConstructionElement>()), Times.Once); Assert.NotNull(newConstructionElement.Construction); }
public ActionResult Create( int constructionId, ConstructionElementCreateRequest constructionElementRequest) { try { var constructionElementModel = _mapper.Map <ConstructionElement>( constructionElementRequest); _service.Create( constructionElementModel, constructionId, constructionElementRequest.ProfileId, constructionElementRequest.SteelId); return(Created( $"construction-elements/{constructionElementModel.Id}", null)); } catch (ArgumentNullException) { return(NotFound()); } catch (ConflictException) { return(Conflict()); } }