public void Create_ShouldCreateMarkGeneralDataPoint()
        {
            // Arrange
            int markId    = _rnd.Next(1, TestData.marks.Count());
            int sectionId = _rnd.Next(1, TestData.generalDataSections.Count());

            var newMarkGeneralDataPoint = new MarkGeneralDataPoint
            {
                Text = "NewCreate",
            };

            // Act
            _service.Create(newMarkGeneralDataPoint, markId, sectionId);

            // Assert
            _repository.Verify(mock => mock.Add(It.IsAny <MarkGeneralDataPoint>()), Times.Once);
            Assert.NotNull(newMarkGeneralDataPoint.Mark);
        }
Ejemplo n.º 2
0
        public ActionResult <MarkGeneralDataPoint> Create(int markId, int sectionId,
                                                          [FromBody] MarkGeneralDataPointCreateRequest markGeneralDataPointRequest)
        {
            var markGeneralDataPointModel = _mapper.Map <MarkGeneralDataPoint>(
                markGeneralDataPointRequest);

            try
            {
                _service.Create(
                    markGeneralDataPointModel,
                    markId,
                    sectionId);
            }
            catch (ArgumentNullException)
            {
                return(NotFound());
            }
            catch (ConflictException)
            {
                return(Conflict());
            }
            return(Created($"mark-general-data-points/{markGeneralDataPointModel.Id}",
                           _mapper.Map <MarkGeneralDataPointResponse>(markGeneralDataPointModel)));
        }