public void EventsIsAlreadySync_ResultListIsEmpty()
        {
            var currentEvent = new SynchronEvent().SetId("123").SetSource("1");
            var needToCheck  = new List <SynchronEvent> {
                currentEvent
            };
            var result = new DifferenceFinder().GetDifferenceToDelete(needToCheck, needToCheck);

            Assert.Equal(0, result.Count);
        }
        public void EventAlreadyExist_ResultListIsEmpty()
        {
            var curretEvent = new SynchronEvent().SetId("123").SetSource("1").SetPlacement("!");
            var needToCheck = new List <SynchronEvent> {
                curretEvent
            };
            var result = new DifferenceFinder().GetDifferenceToPush(needToCheck, needToCheck);

            Assert.Equal(0, result.Count);
        }
        public void EventWhichNeedToAdd_ResultListContainsThisEvent()
        {
            var currentEvent = new SynchronEvent().SetId("123").SetSource("1").SetPlacement("1");
            var needToCheck  = new List <SynchronEvent> {
                currentEvent
            };
            var result = new DifferenceFinder().GetDifferenceToPush(needToCheck, new List <SynchronEvent>());

            Assert.Equal(1, result.Count);
        }
Ejemplo n.º 4
0
        public void FindsSingleDifferences()
        {
            DifferenceFinder finder = new DifferenceFinder();
            var testList            = new List <string>()
            {
                "abcde", "fghij", "klmno", "pqrst", "fguij", "axcye", "wvxyz"
            };
            var result = finder.FindStringsWithOneDifference(testList);

            var expected = "fgij";

            Assert.AreEqual(expected, result.Single());
        }
Ejemplo n.º 5
0
        public void FindDifferences_GivenTwoLists_ShouldReturnsDifferences()
        {
            var differenceFinder = new DifferenceFinder <int>();

            var a = new[] { 1, 2, 3 };
            var b = new[] { 2, 3, 4, 5 };

            var differences = differenceFinder.FindDifferences(a, b);

            Assert.AreEqual(2, differences.ObjectsMissingInFirstList.Count());
            Assert.That(differences.ObjectsMissingInFirstList.Contains(4));
            Assert.That(differences.ObjectsMissingInFirstList.Contains(5));

            Assert.AreEqual(1, differences.ObjectsMissingInSecondList.Count());
            Assert.That(differences.ObjectsMissingInSecondList.Contains(1));
        }
Ejemplo n.º 6
0
        public void FindDifferences_GivenTwoBigLists_ShouldReturnsDifferencesQuickly()
        {
            var stopwatch = Stopwatch.StartNew();

            var differenceFinder = new DifferenceFinder <int>();

            var a = Enumerable.Range(0, 10000);
            var b = Enumerable.Range(5000, 10000);

            var differences = differenceFinder.FindDifferences(a, b);

            Assert.AreEqual(5000, differences.ObjectsMissingInFirstList.Count());
            Assert.AreEqual(5000, differences.ObjectsMissingInSecondList.Count());

            Console.WriteLine("Time needed:" + stopwatch.Elapsed);
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 50);
        }