Ejemplo n.º 1
0
        public void Example1Test()
        {
            var driver1 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 1"))
                          .WithRoute(new[] { 3, 1, 2, 3 })
                          .Build();

            var driver2 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 2"))
                          .WithRoute(new[] { 3, 2, 3, 1 })
                          .Build();

            var driver3 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 3"))
                          .WithRoute(new[] { 4, 2, 3, 4, 5 })
                          .Build();

            var tracker = new TrackerBuilder()
                          .WithDriver(driver1)
                          .WithDriver(driver2)
                          .WithDriver(driver3)
                          .Build();

            var result = tracker.Track();

            Assert.Equal(5, result);
        }
Ejemplo n.º 2
0
        public void TwoDriversWithSameGossip()
        {
            var driver1 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 1"))
                          .WithRoute(new[] { 2, 1, 2 })
                          .Build();

            var driver2 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 1"))
                          .WithRoute(new[] { 2, 1, 2 })
                          .Build();

            var tracker = new TrackerBuilder()
                          .WithDriver(driver1)
                          .WithDriver(driver2)
                          .Build();

            var result = tracker.Track();

            Assert.Equal(1, result);
        }
Ejemplo n.º 3
0
        public void Example2Test()
        {
            var driver1 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 1"))
                          .WithRoute(new[] { 2, 1, 2 })
                          .Build();

            var driver2 = new DriverBuilder()
                          .WithGossip(new Gossip("gossip 2"))
                          .WithRoute(new[] { 5, 2, 8 })
                          .Build();

            var tracker = new TrackerBuilder()
                          .WithDriver(driver1)
                          .WithDriver(driver2)
                          .Build();

            var result = tracker.Track();

            Assert.Equal(-1, result);
        }
Ejemplo n.º 4
0
        public void TwoDriversExchangeAllGossips()
        {
            var gossip1 = new Gossip("Gossip 1");
            var gossip2 = new Gossip("Gossip 2");

            var driver1 = new DriverBuilder()
                          .WithRoute(new[] { 1, 2 })
                          .WithGossip(gossip1)
                          .Build();
            var driver2 = new DriverBuilder()
                          .WithRoute(new[] { 1, 3 })
                          .WithGossip(gossip2)
                          .Build();

            driver1.ReceiveGossips(new[] { driver2 });
            driver2.ReceiveGossips(new[] { driver1 });

            Assert.True(driver1.HasGossip(gossip1));
            Assert.True(driver1.HasGossip(gossip2));

            Assert.True(driver2.HasGossip(gossip1));
            Assert.True(driver2.HasGossip(gossip2));
        }