public void SplitComplementaryController3()
        {
            DbContextOptions <ColorWheelDbContext> options9 = new DbContextOptionsBuilder <ColorWheelDbContext>()
                                                              .UseInMemoryDatabase(databaseName: "ColorWheelDbContext")
                                                              .Options;

            using (ColorWheelDbContext dbContext9 = new ColorWheelDbContext(options9))
            {
                Color color = new Color();
                color.ColorName = "Red-Violet";
                SplitComplementary split = new SplitComplementary();
                split.ColorOneID   = 10;
                split.ColorTwoID   = 3;
                split.ColorThreeID = 5;
                dbContext9.Add(color);
                dbContext9.Add(split);
                dbContext9.SaveChanges();

                var expected       = "Red-Violet";
                var controller     = new SplitComplementaryController(dbContext9);
                var actionResult   = controller.Get(expected);
                var okObjectResult = actionResult as OkObjectResult;
                Assert.IsType <OkObjectResult>(actionResult);
            }
        }
        public IActionResult Get(string id1, string id2, string id3)
        {
            Color color1 = _context.Colors.FirstOrDefault(c => c.ColorName == id1);
            Color color2 = _context.Colors.FirstOrDefault(c => c.ColorName == id2);
            Color color3 = _context.Colors.FirstOrDefault(c => c.ColorName == id3);

            if (color1 == null || color2 == null || color3 == null)
            {
                return(NotFound());
            }

            SplitComplementary palette = new SplitComplementary();

            palette.ColorOneID   = color1.ID;
            palette.ColorTwoID   = color2.ID;
            palette.ColorThreeID = color3.ID;

            SplitComplementary splitComplementary = _context.SplitComplementary.FirstOrDefault(a => a.ColorOneID == palette.ColorOneID);

            if (palette.ColorOneID == splitComplementary.ColorOneID && palette.ColorTwoID == splitComplementary.ColorTwoID && palette.ColorThreeID == splitComplementary.ColorThreeID)
            {
                return(Ok(true));
            }

            return(Ok(false));
        }
        public void CanGetIDforSplitComplementary3()
        {
            SplitComplementary splitComplementary = new SplitComplementary();

            splitComplementary.ColorOneID   = 12;
            splitComplementary.ColorTwoID   = 5;
            splitComplementary.ColorThreeID = 7;

            Assert.Equal(12, splitComplementary.ColorOneID);
            Assert.Equal(5, splitComplementary.ColorTwoID);
            Assert.Equal(7, splitComplementary.ColorThreeID);
        }
        public void CanGetIDforSplitComplementary1()
        {
            SplitComplementary splitComplementary = new SplitComplementary();

            splitComplementary.ColorOneID   = 1;
            splitComplementary.ColorTwoID   = 6;
            splitComplementary.ColorThreeID = 8;

            Assert.Equal(1, splitComplementary.ColorOneID);
            Assert.Equal(6, splitComplementary.ColorTwoID);
            Assert.Equal(8, splitComplementary.ColorThreeID);
        }
        public IActionResult Get(string id)
        {
            Color color = _context.Colors.FirstOrDefault(c => c.ColorName == id);
            SplitComplementary splitComplimentary = _context.SplitComplementary.FirstOrDefault(a => a.ColorOneID == color.ID || a.ColorTwoID == color.ID || a.ColorThreeID == color.ID);

            if (color == null || splitComplimentary == null)
            {
                return(NotFound());
            }

            Color color1 = _context.Colors.FirstOrDefault(c => c.ID == splitComplimentary.ColorOneID);
            Color color2 = _context.Colors.FirstOrDefault(c => c.ID == splitComplimentary.ColorTwoID);
            Color color3 = _context.Colors.FirstOrDefault(c => c.ID == splitComplimentary.ColorThreeID);

            List <Color> palette = new List <Color> {
                color1, color2, color3
            };

            return(Ok(new { palette }));
        }
예제 #6
0
        public void SplitComplementary_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new SplitComplementary();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(27, 46, 49),
                    new HSV(67, 46, 49),
                    new HSV(67, 0, 46),
                    new HSV(67, 0, 49),
                    new HSV(67, 0, 51)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
예제 #7
0
        public void CanReturn404StatusCode()
        {
            DbContextOptions <ColorWheelDbContext> moreFakeOptions = new DbContextOptionsBuilder <ColorWheelDbContext>()
                                                                     .UseInMemoryDatabase(databaseName: "ColorWheelDbContext")
                                                                     .Options;

            using (ColorWheelDbContext fakeDB = new ColorWheelDbContext(moreFakeOptions))
            {
                Color yellow = new Color {
                    ID = 1, ColorName = "Yellow", HexCode = "#FEFE33"
                };
                Color blueViolet = new Color {
                    ID = 6, ColorName = "Blue-Violet", HexCode = "#4424D6"
                };
                Color redViolet = new Color {
                    ID = 8, ColorName = "Red-Violet", HexCode = "#C21460"
                };

                SplitComplementary splitComplementary = new SplitComplementary();
                splitComplementary.ColorOneID   = 1;
                splitComplementary.ColorTwoID   = 6;
                splitComplementary.ColorThreeID = 8;

                fakeDB.Add(yellow);
                fakeDB.Add(blueViolet);
                fakeDB.Add(redViolet);
                fakeDB.Add(splitComplementary);
                fakeDB.SaveChanges();

                var color1 = "Yellow";
                var color2 = "Blue-Violet";
                var color3 = "Red";

                var controller       = new SplitComplementaryController(fakeDB);
                var moreActionResult = controller.Get(color1, color2, color3);
                var notFoundResult   = moreActionResult as NotFoundResult;

                Assert.IsType <NotFoundResult>(moreActionResult);
            }
        }