Example #1
0
        public void CheckAndRemoveDuplicatesTest()
        {
            var servers = new Servers();
            for (int a = 1; a <= count; a++)
            {
                servers.Add(createServer("server " + a));
            }
            servers.Named("server " + count).Name = "server " + fakeId;

            Assert.AreEqual(count, servers.All.Count());
            Assert.AreEqual(count * count, (from server in servers.All from channel in server.Channels select channel).Count());
            Assert.AreEqual(count * count * count, (from server in servers.All from channel in server.Channels from bot in channel.Bots select bot).Count());
            Assert.AreEqual(count * count * count * count, (from server in servers.All from channel in server.Channels from bot in channel.Bots from packet in bot.Packets select packet).Count());

            XG.Business.Helper.Objects.CheckAndRemoveDuplicates(servers);

            int newCount = count - 1;
            Assert.AreEqual(newCount, servers.All.Count());
            Assert.AreEqual(newCount * newCount, (from server in servers.All from channel in server.Channels select channel).Count());
            Assert.AreEqual(newCount * newCount * newCount, (from server in servers.All from channel in server.Channels from bot in channel.Bots select bot).Count());
            Assert.AreEqual(newCount * newCount * newCount * newCount, (from server in servers.All from channel in server.Channels from bot in channel.Bots from packet in bot.Packets select packet).Count());
        }