Пример #1
0
        public void FromHandleTest()
        {
            // Arrange
            int expected = 23;

            using (var profile = Profile.CreatePlaceholder(null))
            {
                using (var ncl = NamedColorList.Create(null, 256, 3, "pre", "post"))
                {
                    for (uint i = 0; i < 256; i++)
                    {
                        ushort[] pcs = new ushort[3] {
                            (ushort)i, (ushort)i, (ushort)i
                        };
                        ushort[] colorant = new ushort[16];
                        colorant[0] = colorant[1] = colorant[2] = (ushort)i;

                        bool added = ncl.Add($"#{i}", pcs, colorant);
                    }

                    profile.WriteTag(TagSignature.NamedColor2, ncl.Handle);
                }

                // Act
                using (var roNcl = NamedColorList.FromHandle(profile.ReadTag(TagSignature.NamedColor2)))
                {
                    // Assert
                    int actual = roNcl[$"#{expected}"];
                    Assert.AreEqual(expected, actual);
                }
            }
        }
Пример #2
0
        public void IndexerTest()
        {
            // Arrange
            int expected = 23;

            using (var ncl = NamedColorList.Create(null, 256, 3, "pre", "post"))
            {
                for (uint i = 0; i < 256; i++)
                {
                    ushort[] pcs = new ushort[3] {
                        (ushort)i, (ushort)i, (ushort)i
                    };
                    ushort[] colorant = new ushort[16];
                    colorant[0] = colorant[1] = colorant[2] = (ushort)i;

                    bool added = ncl.Add($"#{i}", pcs, colorant);
                }

                // Act
                int actual = ncl[$"#{expected}"];

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Пример #3
0
        public void CreateTest()
        {
            // Arrange

            // Act
            using (var ncl = NamedColorList.Create(null, 0, 4, "prefix", "suffix"))
            {
                // Assert
                Assert.IsNotNull(ncl);
            }
        }
Пример #4
0
        public void DuplicateTest()
        {
            // Arrange

            // Act
            using (var ncl = NamedColorList.Create(null, 256, 3, "pre", "post"))
                using (var duplicate = ncl.Duplicate())
                {
                    // Assert
                    Assert.IsNotNull(duplicate);
                }
        }
Пример #5
0
        public void IndexerTestNotFound()
        {
            // Arrange
            int expected = -1;

            using (var ncl = NamedColorList.Create(null, 256, 3, null, null))
            {
                // Act
                int actual = ncl["notfound"];

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Пример #6
0
        public void CountTestEmptyList()
        {
            // Arrange
            uint expected = 0;

            using (var ncl = NamedColorList.Create(null, 256, 3, null, null))
            {
                // Act
                var actual = ncl.Count;

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Пример #7
0
        public void AddTest()
        {
            // Arrange
            using (var ncl = NamedColorList.Create(null, 256, 3, "pre", "post"))
            {
                ushort[] pcs = new ushort[3] {
                    1, 1, 1
                };
                ushort[] colorant = new ushort[16];
                colorant[0] = colorant[1] = colorant[2] = 1;

                // Act
                bool added = ncl.Add("#1", pcs, colorant);

                // Assert
                Assert.IsTrue(added);
            }
        }
Пример #8
0
        public void GetInfoTest()
        {
            // Arrange
            string expectedPrefix = "pre";
            string expectedSuffix = "post";
            uint   expectedNColor = 42;
            string expectedName   = $"#{expectedNColor}";

            using (var ncl = NamedColorList.Create(null, 256, 3, expectedPrefix, expectedSuffix))
            {
                for (uint i = 0; i < 256; i++)
                {
                    ushort[] pcs = new ushort[3] {
                        (ushort)i, (ushort)i, (ushort)i
                    };
                    ushort[] colorant = new ushort[16];
                    colorant[0] = colorant[1] = colorant[2] = (ushort)i;

                    // Act
                    bool added = ncl.Add($"#{i}", pcs, colorant);
                }

                // Act
                bool getInfo = ncl.GetInfo(expectedNColor, out string actualName, out string actualPrefix, out string actualSuffix,
                                           out ushort[] actualPcs, out ushort[] actualColorant);

                // Assert
                Assert.AreEqual(expectedName, actualName);
                Assert.AreEqual(expectedPrefix, actualPrefix);
                Assert.AreEqual(expectedSuffix, actualSuffix);
                for (ushort i = 0; i < 3; i++)
                {
                    Assert.AreEqual(expectedNColor, actualPcs[i]);
                    Assert.AreEqual(expectedNColor, actualColorant[i]);
                }
            }
        }