public void CreateColor_NullName_ThrowsInvalidDataException()
        {
            Mock <IColorRepository> colorRepository = new Mock <IColorRepository>();
            ColorService            colorService    = new ColorService(colorRepository.Object);
            Color color = new Color();

            Action actual = () => colorService.Create(color);

            Assert.Throws <InvalidDataException>(actual);
        }
        public void CreateColor_SpecifiedId_ThrowsNotSupportedException()
        {
            Mock <IColorRepository> colorRepository = new Mock <IColorRepository>();
            ColorService            colorService    = new ColorService(colorRepository.Object);
            Color color = new Color()
            {
                Id = 1
            };

            Action actual = () => colorService.Create(color);

            Assert.Throws <NotSupportedException>(actual);
        }
        public async Task <IActionResult> PostColor([FromBody] Color color)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (colorService.GetAll().Result.Where(m => m.ColorValue == color.ColorValue).Count() > 0)
            {
                return(BadRequest());
            }
            color.StatusId = new Guid("87577063-322E-4901-98D2-FF519341D992");
            await colorService.Create(color);

            return(CreatedAtAction("GetColor", new { id = color.ColorId }, color));
        }