public void Difference_Identical()
        {
            IEnumerable <string> one = new[] { "one" };
            var actual = Program.Difference(one, one);

            EnumerableExtensions.EnumerateSame(EmptyStringSequence, actual);
        }
示例#2
0
        public void ComputeTiles_SizeOfTile()
        {
            var size     = new Size(254, 254);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 1);
            var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(size), "0_0") };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#3
0
        public void ComputeTiles_TwoPixelsBiggerThanTileWithOverlapOfTwo()
        {
            var size     = new Size(256, 256);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 2);
            var expected = new[]
            {
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(255, 255)), "0_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 252), new Point(255, 255)), "0_1"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(252, 0), new Point(255, 255)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(252, 252), new Point(255, 255)), "1_1"),
            };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#4
0
        public void ComputeTiles_OnePixelBiggerThanTile()
        {
            var size     = new Size(255, 255);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 1);
            var expected = new[]
            {
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 254)), "0_1"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(254, 254)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(254, 254)), "1_1"),
            };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#5
0
        public void ComputeTiles_BiggerThanTileWithOverlapOfThree()
        {
            var size     = new Size(300, 375);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 3);
            var expected = new[]
            {
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(256, 256)), "0_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 251), new Point(256, 374)), "0_1"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(251, 0), new Point(299, 256)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(251, 251), new Point(299, 374)), "1_1"),
            };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
        public void GenerateCollectionTiles_SixtyFour()
        {
            var expected = new[]
            {
                new ImageCollectionTile(0, 0, 0, new[]
                {
                    TestIds[0],
                    TestIds[1],
                    TestIds[2],
                    TestIds[3],
                    TestIds[4],
                    TestIds[5],
                    TestIds[6],
                    TestIds[7],
                    TestIds[8],
                    TestIds[9],
                    TestIds[10],
                    TestIds[11],
                    TestIds[12],
                    TestIds[13],
                    TestIds[14],
                    TestIds[15],
                }
                                        ),
                new ImageCollectionTile(0, 1, 16, new[]
                {
                    TestIds[16],
                    TestIds[17],
                    TestIds[18],
                    TestIds[19],
                    TestIds[20],
                    TestIds[21],
                    TestIds[22],
                    TestIds[23],
                    TestIds[24],
                    TestIds[25],
                    TestIds[26],
                    TestIds[27],
                    TestIds[28],
                    TestIds[29],
                }
                                        ),
            };
            var actual = DeepZoomCollection.GenerateCollectionTiles(TestIds, 64);

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
        public void GenerateCollectionTiles_OneToThirtyTwo()
        {
            var expected = new[]
            {
                new ImageCollectionTile(0, 0, 0, new[]
                {
                    TestIds[0],
                    TestIds[1],
                    TestIds[2],
                    TestIds[3],
                    TestIds[4],
                    TestIds[5],
                    TestIds[6],
                    TestIds[7],
                    TestIds[8],
                    TestIds[9],
                    TestIds[10],
                    TestIds[11],
                    TestIds[12],
                    TestIds[13],
                    TestIds[14],
                    TestIds[15],
                    TestIds[16],
                    TestIds[17],
                    TestIds[18],
                    TestIds[19],
                    TestIds[20],
                    TestIds[21],
                    TestIds[22],
                    TestIds[23],
                    TestIds[24],
                    TestIds[25],
                    TestIds[26],
                    TestIds[27],
                    TestIds[28],
                    TestIds[29],
                }
                                        ),
            };

            for (var i = 0; i < 6; i++)
            {
                var levelSize = (int)Math.Pow(2, i);
                var actual    = DeepZoomCollection.GenerateCollectionTiles(TestIds, levelSize);
                EnumerableExtensions.EnumerateSame(expected, actual);
            }
        }
示例#8
0
        public void ComputeTiles_OriginalSize()
        {
            var size     = new Size(1200, 1500);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 1);
            var expected = new[]
            {
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 508)), "0_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 507), new Point(254, 762)), "0_2"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 761), new Point(254, 1016)), "0_3"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 1015), new Point(254, 1270)), "0_4"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 1269), new Point(254, 1499)), "0_5"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(508, 254)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(508, 508)), "1_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 507), new Point(508, 762)), "1_2"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 761), new Point(508, 1016)), "1_3"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 1015), new Point(508, 1270)), "1_4"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 1269), new Point(508, 1499)), "1_5"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 0), new Point(762, 254)), "2_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 253), new Point(762, 508)), "2_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 507), new Point(762, 762)), "2_2"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 761), new Point(762, 1016)), "2_3"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 1015), new Point(762, 1270)), "2_4"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 1269), new Point(762, 1499)), "2_5"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 0), new Point(1016, 254)), "3_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 253), new Point(1016, 508)), "3_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 507), new Point(1016, 762)), "3_2"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 761), new Point(1016, 1016)), "3_3"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 1015), new Point(1016, 1270)), "3_4"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 1269), new Point(1016, 1499)), "3_5"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 0), new Point(1199, 254)), "4_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 253), new Point(1199, 508)), "4_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 507), new Point(1199, 762)), "4_2"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 761), new Point(1199, 1016)), "4_3"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 1015), new Point(1199, 1270)), "4_4"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 1269), new Point(1199, 1499)), "4_5"),
            };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#9
0
        public void ComputeTiles_BigWithDoubleOverlap()
        {
            var size     = new Size(700, 700);
            var actual   = DeepZoomImage.ComputeTiles(size, 254, 1);
            var expected = new[]
            {
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 508)), "0_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 507), new Point(254, 699)), "0_2"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(508, 254)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(508, 508)), "1_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 507), new Point(508, 699)), "1_2"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 0), new Point(699, 254)), "2_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 253), new Point(699, 508)), "2_1"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 507), new Point(699, 699)), "2_2"),
            };

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#10
0
        public void Slice_SquareLogo()
        {
            Assert.AreEqual(10, DeepZoomImage.DetermineMaximumLevel(SquareLogoSize));
            using (var sourceBitmap = new Bitmap(SquareLogoSize.Width, SquareLogoSize.Height))
            {
                var tester = new Action <int, IEnumerable <Size> > ((level, expectedSliceSizes) =>
                {
                    var levelSize        = DeepZoomImage.ComputeLevelSize(SquareLogoSize, level);
                    var tiles            = DeepZoomImage.ComputeTiles(levelSize, 254, 1);
                    var slices           = DeepZoomImage.Slice(sourceBitmap, tiles);
                    var actualSliceSizes = slices.Map(pair => pair.First.Size);
                    EnumerableExtensions.EnumerateSame(expectedSliceSizes, actualSliceSizes);
                }
                                                                    );

                tester(10, new[]
                {
                    new Size(255, 255), new Size(255, 256), new Size(255, 193),
                    new Size(256, 255), new Size(256, 256), new Size(256, 193),
                    new Size(193, 255), new Size(193, 256), new Size(193, 193),
                }
                       );
                tester(9, new[]
                {
                    new Size(255, 255), new Size(255, 97),
                    new Size(97, 255), new Size(97, 97),
                }
                       );
                tester(8, new[] { new Size(175, 175) });
                tester(7, new[] { new Size(88, 88) });
                tester(6, new[] { new Size(44, 44) });
                tester(5, new[] { new Size(22, 22) });
                tester(4, new[] { new Size(11, 11) });
                tester(3, new[] { new Size(6, 6) });
                tester(2, new[] { new Size(3, 3) });
                tester(1, new[] { new Size(2, 2) });
                tester(0, new[] { new Size(1, 1) });
            }
        }
示例#11
0
        // TODO: Move to re-usable class library
        internal static void AssertStreamsAreEqual <T>(string expectedResourceFileName, MemoryStream actualStream)
        {
            using (var expectedStream = AssemblyExtensions.OpenScopedResourceStream <T> (expectedResourceFileName))
            {
                var expectedBytes = expectedStream.EnumerateBytes();

                actualStream.Seek(0, SeekOrigin.Begin);
                var actualBytes = actualStream.EnumerateBytes();

                try
                {
                    EnumerableExtensions.EnumerateSame(expectedBytes, actualBytes);
                }
                catch (AssertionException)
                {
                    actualStream.Seek(0, SeekOrigin.Begin);
                    using (var fileStream = expectedResourceFileName.CreateWriteStream())
                    {
                        actualStream.WriteTo(fileStream);
                    }
                    throw;
                }
            }
        }
        public void GenerateCollectionTiles_OneTwentyEight()
        {
            var expected = new[]
            {
                new ImageCollectionTile(0, 0, 0, new[]
                {
                    TestIds[0],
                    TestIds[1],
                    TestIds[2],
                    TestIds[3],
                }
                                        ),
                new ImageCollectionTile(0, 1, 4, new[]
                {
                    TestIds[4],
                    TestIds[5],
                    TestIds[6],
                    TestIds[7],
                }
                                        ),
                new ImageCollectionTile(1, 0, 8, new[]
                {
                    TestIds[8],
                    TestIds[9],
                    TestIds[10],
                    TestIds[11],
                }
                                        ),
                new ImageCollectionTile(1, 1, 12, new[]
                {
                    TestIds[12],
                    TestIds[13],
                    TestIds[14],
                    TestIds[15],
                }
                                        ),
                new ImageCollectionTile(0, 2, 16, new[]
                {
                    TestIds[16],
                    TestIds[17],
                    TestIds[18],
                    TestIds[19],
                }
                                        ),
                new ImageCollectionTile(0, 3, 20, new[]
                {
                    TestIds[20],
                    TestIds[21],
                    TestIds[22],
                    TestIds[23],
                }
                                        ),
                new ImageCollectionTile(1, 2, 24, new[]
                {
                    TestIds[24],
                    TestIds[25],
                    TestIds[26],
                    TestIds[27],
                }
                                        ),
                new ImageCollectionTile(1, 3, 28, new[]
                {
                    TestIds[28],
                    TestIds[29],
                }
                                        ),
            };
            var actual = DeepZoomCollection.GenerateCollectionTiles(TestIds, 128);

            EnumerableExtensions.EnumerateSame(expected, actual);
        }
示例#13
0
        public void Difference_Empty()
        {
            var actual = Program.Difference(new string[] {}, new string[] {});

            EnumerableExtensions.EnumerateSame(EmptyStringSequence, actual);
        }
示例#14
0
        public void Compare_DifferentButIdenticalAssembly()
        {
            var actual = Compare(_baseline, _manual);

            EnumerableExtensions.EnumerateSame(EmptyStringSequence, actual.Lines());
        }
示例#15
0
        public void Compare_SameAssembly()
        {
            var actual = Compare(_baseline, _baseline);

            EnumerableExtensions.EnumerateSame(EmptyStringSequence, actual.Lines());
        }
示例#16
0
        public void Difference_LastLeftEqual()
        {
            var actual = Program.Difference(new[] { "c" }, new[] { "a", "b", "c" });

            EnumerableExtensions.EnumerateSame(new[] { "a", "b" }, actual);
        }
示例#17
0
        public void Difference_OnlyItemsOnTheRight()
        {
            var actual = Program.Difference(EmptyStringSequence, new[] { "a", "b", "c" });

            EnumerableExtensions.EnumerateSame(new[] { "a", "b", "c" }, actual);
        }
示例#18
0
        public void Difference_OnlyOneItemOnTheLeft()
        {
            var actual = Program.Difference(new[] { "a" }, EmptyStringSequence);

            EnumerableExtensions.EnumerateSame(new[] { "a" }, actual);
        }
示例#19
0
        public void Difference_AlternatingWithLastTwoOnRight()
        {
            var actual = Program.Difference(new[] { "c" }, new[] { "b", "d", "e" });

            EnumerableExtensions.EnumerateSame(new[] { "b", "c", "d", "e" }, actual);
        }
示例#20
0
        public void Difference_OneTooManyAtTheBeginningOfRight()
        {
            var actual = Program.Difference(new[] { "b" }, new[] { "a", "b" });

            EnumerableExtensions.EnumerateSame(new[] { "a" }, actual);
        }
        public void GenerateCollectionTiles_TwoFiftySix()
        {
            var expected = new[]
            {
                new ImageCollectionTile(0, 0, 0, new[]
                {
                    TestIds[0],
                }
                                        ),
                new ImageCollectionTile(0, 1, 1, new[]
                {
                    TestIds[1],
                }
                                        ),
                new ImageCollectionTile(1, 0, 2, new[]
                {
                    TestIds[2],
                }
                                        ),
                new ImageCollectionTile(1, 1, 3, new[]
                {
                    TestIds[3],
                }
                                        ),
                new ImageCollectionTile(0, 2, 4, new[]
                {
                    TestIds[4],
                }
                                        ),
                new ImageCollectionTile(0, 3, 5, new[]
                {
                    TestIds[5],
                }
                                        ),
                new ImageCollectionTile(1, 2, 6, new[]
                {
                    TestIds[6],
                }
                                        ),
                new ImageCollectionTile(1, 3, 7, new[]
                {
                    TestIds[7],
                }
                                        ),
                new ImageCollectionTile(2, 0, 8, new[]
                {
                    TestIds[8],
                }
                                        ),
                new ImageCollectionTile(2, 1, 9, new[]
                {
                    TestIds[9],
                }
                                        ),
                new ImageCollectionTile(3, 0, 10, new[]
                {
                    TestIds[10],
                }
                                        ),
                new ImageCollectionTile(3, 1, 11, new[]
                {
                    TestIds[11],
                }
                                        ),
                new ImageCollectionTile(2, 2, 12, new[]
                {
                    TestIds[12],
                }
                                        ),
                new ImageCollectionTile(2, 3, 13, new[]
                {
                    TestIds[13],
                }
                                        ),
                new ImageCollectionTile(3, 2, 14, new[]
                {
                    TestIds[14],
                }
                                        ),
                new ImageCollectionTile(3, 3, 15, new[]
                {
                    TestIds[15],
                }
                                        ),
                new ImageCollectionTile(0, 4, 16, new[]
                {
                    TestIds[16],
                }
                                        ),
                new ImageCollectionTile(0, 5, 17, new[]
                {
                    TestIds[17],
                }
                                        ),
                new ImageCollectionTile(1, 4, 18, new[]
                {
                    TestIds[18],
                }
                                        ),
                new ImageCollectionTile(1, 5, 19, new[]
                {
                    TestIds[19],
                }
                                        ),
                new ImageCollectionTile(0, 6, 20, new[]
                {
                    TestIds[20],
                }
                                        ),
                new ImageCollectionTile(0, 7, 21, new[]
                {
                    TestIds[21],
                }
                                        ),
                new ImageCollectionTile(1, 6, 22, new[]
                {
                    TestIds[22],
                }
                                        ),
                new ImageCollectionTile(1, 7, 23, new[]
                {
                    TestIds[23],
                }
                                        ),
                new ImageCollectionTile(2, 4, 24, new[]
                {
                    TestIds[24],
                }
                                        ),
                new ImageCollectionTile(2, 5, 25, new[]
                {
                    TestIds[25],
                }
                                        ),
                new ImageCollectionTile(3, 4, 26, new[]
                {
                    TestIds[26],
                }
                                        ),
                new ImageCollectionTile(3, 5, 27, new[]
                {
                    TestIds[27],
                }
                                        ),
                new ImageCollectionTile(2, 6, 28, new[]
                {
                    TestIds[28],
                }
                                        ),
                new ImageCollectionTile(2, 7, 29, new[]
                {
                    TestIds[29],
                }
                                        ),
            };
            var actual = DeepZoomCollection.GenerateCollectionTiles(TestIds, 256);

            EnumerableExtensions.EnumerateSame(expected, actual);
        }