Exemplo n.º 1
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));
            });
        }
Exemplo n.º 2
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);
        }