Exemplo n.º 1
0
        public IActionResult CreateBike(CreateBikeRequest bikeRequest)
        {
            var bikeToInsert = _mapper.Map <BikeDto>(bikeRequest);
            var bike         = _bikeService.CreateNewBike(bikeToInsert);

            return(CreatedAtAction(nameof(GetBike), new { id = bike.Id }, bike));
        }
Exemplo n.º 2
0
        public void CreateBike_Returns_BikeResource()
        {
            var expected = new BikeDto();
            var request  = new CreateBikeRequest();

            mockMapper.Setup(m => m.Map <BikeDto>(It.IsAny <CreateBikeRequest>())).Returns(new BikeDto());
            mockService.Setup(r => r.CreateNewBike(It.IsAny <BikeDto>())).Returns(expected);
            mockService.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(expected);
            var result = bikesController.CreateBike(request) as CreatedAtActionResult;
            var actual = result.Value as BikeDto;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void CreateBike_Returns_Ok_Result()
        {
            var expected = new BikeDto();
            var request  = new CreateBikeRequest();

            mockMapper.Setup(m => m.Map <BikeDto>(It.IsAny <CreateBikeRequest>())).Returns(new BikeDto());
            mockService.Setup(r => r.CreateNewBike(It.IsAny <BikeDto>())).Returns(expected);
            mockService.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(expected);
            var result = bikesController.CreateBike(request) as CreatedAtActionResult;

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