コード例 #1
0
        public void FlightInfoDiffOnlyOutputTest()
        {
            Collection <FlightInfo> nonActualFlightInfo = MockFlightData.FetchNonActualFlightInfo();

            nonActualFlightInfo.Add(new FlightInfo(2265, DateTime.Parse("06/24/07"), "DEN", DateTime.Parse("06/24/07 12:22"), "ORD", DateTime.Parse("06/24/07 15:32"), "PILOT"));

            Collection <FlightInfo> actualFlightInfo = MockFlightData.FetchActualFlightInfo();

            actualFlightInfo.Add(new FlightInfo(1265, DateTime.Parse("06/25/07"), "DEN", DateTime.Parse("06/25/07 12:22"), "ORD", DateTime.Parse("06/25/07 15:32"), "INF"));

            DiffCollectionGenerator <FlightInfo> diffCollectionGenerator = new DiffCollectionGenerator <FlightInfo>("Flight", "Date", "DepartureCity", "ArrivalCity");

            diffCollectionGenerator.MissingName = "OPT ONLY";
            diffCollectionGenerator.AddedName   = "SBS ONLY";
            DiffCollection <FlightInfo> diffs   = diffCollectionGenerator.GenerateDiffs(actualFlightInfo, nonActualFlightInfo);
            List <DiffEntry>            entries = new List <DiffEntry>(diffs.Entries);

            Assert.AreEqual(7, diffs.Count);
            Assert.AreEqual(8, entries.Count);
            Assert.AreEqual(DiffType.Changed, entries[0].DiffType);
            Assert.AreEqual(DiffType.Changed, entries[1].DiffType);
            Assert.AreEqual(DiffType.Changed, entries[2].DiffType);
            Assert.AreEqual(DiffType.Changed, entries[3].DiffType);
            Assert.AreEqual(DiffType.Changed, entries[4].DiffType);
            Assert.AreEqual(DiffType.Changed, entries[5].DiffType);
            Assert.AreEqual(DiffType.Missing, entries[6].DiffType);
            Assert.AreEqual(DiffType.Added, entries[7].DiffType);
        }
コード例 #2
0
        public void ThreadedFlightInfoDiff()
        {
            ThreadedRepeat(100, (index, threadAsserter) =>
            {
                Collection <FlightInfo> nonActualFlightInfo = MockFlightData.FetchNonActualFlightInfo();
                Collection <FlightInfo> actualFlightInfo    = MockFlightData.FetchActualFlightInfo();

                DiffCollectionGenerator <FlightInfo> diffCollectionGenerator = new DiffCollectionGenerator <FlightInfo>("Flight", "Date", "DepartureCity", "ArrivalCity");
                DiffCollection <FlightInfo> diffs = diffCollectionGenerator.GenerateDiffs(actualFlightInfo, nonActualFlightInfo);
                List <DiffEntry> entries          = new List <DiffEntry>(diffs.Entries);
                int diffCount    = diffs.Count;
                int entriesCount = entries.Count;

                threadAsserter.Assert(() => Assert.AreEqual(5, diffCount));
                threadAsserter.Assert(() => Assert.AreEqual(6, entriesCount));

                Thread.Sleep(100);

                diffs             = diffCollectionGenerator.GenerateDiffs(actualFlightInfo, nonActualFlightInfo);
                int diffCount2    = diffs.Count;
                int entriesCount2 = entries.Count;

                threadAsserter.Assert(() => Assert.AreEqual(5, diffCount2));
                threadAsserter.Assert(() => Assert.AreEqual(6, entriesCount2));
            });
        }
コード例 #3
0
        public void MultiLevelKey()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();

            expected.Add(new Item(2, "Scotty", 50));
            actual.Add(new Item(2, "Scotty", 55));

            expected.Add(new Item(2, "Bones", 58));
            actual.Add(new Item(2, "Bones", 60));

            expected.Add(new Item(3, "Kirk", 45));
            actual.Add(new Item(3, "Kirk", 48));

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Id", "Name");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);
            List <DiffEntry> entries             = new List <DiffEntry>(diffs.Entries);

            Assert.AreEqual(3, diffs.Count);

            Assert.AreEqual("50", entries[0].BaselineValue);
            Assert.AreEqual("55", entries[0].NewValue);

            Assert.AreEqual("58", entries[1].BaselineValue);
            Assert.AreEqual("60", entries[1].NewValue);

            Assert.AreEqual("45", entries[2].BaselineValue);
            Assert.AreEqual("48", entries[2].NewValue);
        }
コード例 #4
0
        public void GenerateNotNull()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Id");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);

            Assert.IsNotNull(diffs);
        }
コード例 #5
0
        public void OneDifferenceFriendlyFormat()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();

            expected.Add(new Item(2, "Scotty", 35));
            actual.Add(new Item(2, "Bones", 35));

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Id");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);
            List <DiffEntry> entries             = new List <DiffEntry>(diffs.Entries);

            Assert.AreEqual(1, diffs.Count);
            Assert.AreEqual("Scotty", entries[0].BaselineValue);
            Assert.AreEqual("Bones", entries[0].NewValue);
        }
コード例 #6
0
        public void TwoDifferencesPerformance()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();

            for (int i = 0; i < 18000; i++)
            {
                expected.Add(new Item(i, "Scotty", i, DateTime.Now.AddHours(i).Date));
                actual.Add(new Item(i, "Bones", i + 1, DateTime.Now.AddHours(i).Date));
            }

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Day", "Id");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);

            Assert.AreEqual(18000, diffs.Count);
        }
コード例 #7
0
        public void OneDifferencePerformance()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();
            const int      count    = 20000;

            for (int i = 0; i < count; i++)
            {
                expected.Add(new Item(i, "Scotty", i, DateTime.Now.Date));
                actual.Add(new Item(i, "Bones", i, DateTime.Now.Date));
            }

            CodeTimer timer = CodeTimer.Start();

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Day", "Id");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);

            CodeTimer.WriteMilliseconds(timer);

            Assert.AreEqual(count, diffs.Count);
        }
コード例 #8
0
        public void OneDifferenceInTwoItems()
        {
            ItemCollection expected = new ItemCollection();
            ItemCollection actual   = new ItemCollection();

            expected.Add(new Item(2, "Scotty", 50));
            actual.Add(new Item(2, "Scotty", 55));

            expected.Add(new Item(3, "Kirk", 45));
            actual.Add(new Item(3, "Kirk", 48));

            DiffCollectionGenerator <Item> diffCollectionGenerator = new DiffCollectionGenerator <Item>("Id");
            DiffCollection <Item>          diffs = diffCollectionGenerator.GenerateDiffs(expected, actual);
            List <DiffEntry> entries             = new List <DiffEntry>(diffs.Entries);

            Assert.AreEqual(2, diffs.Count);

            Assert.AreEqual("50", entries[0].BaselineValue);
            Assert.AreEqual("55", entries[0].NewValue);

            Assert.AreEqual("45", entries[1].BaselineValue);
            Assert.AreEqual("48", entries[1].NewValue);
        }