public IActionResult CreateBikeColorIfNotExists(CreateBikeColorRequest request) { var colorToInsert = _mapper.Map <BikeColorDto>(request); var color = _bikeColorService.CreateColorIfNotExists(colorToInsert); return(CreatedAtAction(nameof(GetBikeColor), new { id = color.Id }, color)); }
public void CreateBikeColorIfNotExists_Returns_BikeColorResource() { var expected = new BikeColorDto(); var request = new CreateBikeColorRequest(); mockMapper.Setup(m => m.Map <BikeColorDto>(It.IsAny <CreateBikeColorRequest>())).Returns(new BikeColorDto()); mockService.Setup(r => r.CreateColorIfNotExists(It.IsAny <BikeColorDto>())).Returns(expected); var result = colorController.CreateBikeColorIfNotExists(request) as CreatedAtActionResult; var actual = result.Value as BikeColorDto; Assert.AreEqual(expected, actual); }
public void CreateBikeColorIfNotExists_Returns_Ok_Result() { var expected = new BikeColorDto(); var request = new CreateBikeColorRequest(); mockMapper.Setup(m => m.Map <BikeColorDto>(It.IsAny <CreateBikeColorRequest>())).Returns(new BikeColorDto()); mockService.Setup(r => r.CreateColorIfNotExists(It.IsAny <BikeColorDto>())).Returns(expected); var result = colorController.CreateBikeColorIfNotExists(request) as CreatedAtActionResult; Assert.NotNull(result); Assert.AreEqual(201, result.StatusCode); }