Ejemplo n.º 1
0
        public IActionResult CreateBikeModel(CreateBikeModelRequest modelRequest)
        {
            var modelToInsert = _mapper.Map <BikeModelDto>(modelRequest);
            var model         = _bikeModelService.CreateBikeModel(modelToInsert);

            return(CreatedAtAction(nameof(GetBikeModel), new { id = model.Id }, model));
        }
Ejemplo n.º 2
0
        public void CreateBike_Returns_BikeModelResource()
        {
            var expected = new BikeModelDto();
            var request  = new CreateBikeModelRequest();

            mockMapper.Setup(m => m.Map <BikeModelDto>(It.IsAny <CreateBikeModelRequest>())).Returns(new BikeModelDto());
            mockService.Setup(r => r.CreateBikeModel(It.IsAny <BikeModelDto>())).Returns(expected);
            mockService.Setup(r => r.GetModelById(It.IsAny <Guid>())).Returns(expected);
            var result = bikeModelController.CreateBikeModel(request) as CreatedAtActionResult;
            var actual = result.Value as BikeModelDto;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void CreateBike_Returns_Ok_Result()
        {
            var expected = new BikeModelDto();
            var request  = new CreateBikeModelRequest();

            mockMapper.Setup(m => m.Map <BikeModelDto>(It.IsAny <CreateBikeModelRequest>())).Returns(new BikeModelDto());
            mockService.Setup(r => r.CreateBikeModel(It.IsAny <BikeModelDto>())).Returns(expected);
            mockService.Setup(r => r.GetModelById(It.IsAny <Guid>())).Returns(expected);
            var result = bikeModelController.CreateBikeModel(request) as CreatedAtActionResult;

            Assert.NotNull(result);
            Assert.AreEqual(201, result.StatusCode);
        }