public void Contents_Preserved_Through_Save_Load()
        {
            var chats = new ChatCollection((Data.GetChatCollectionA().Union(Data.GetChatCollectionB())));

            var db = new XmlChatDatabase("chats.xml");
            db.SaveChats(chats);

            var loaded = db.LoadChats();

            Assert.AreEqual(chats, loaded);
        }
        public void Speed_Test_Large_Save_Load()
        {
            var chats = Data.GetLargeChatCollection();
            var db = new XmlChatDatabase("large.xml");

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            db.SaveChats(chats);
            stopwatch.Stop();

            var stopwatch2 = new Stopwatch();
            stopwatch2.Start();
            var loaded = db.LoadChats();
            stopwatch2.Stop();

            Assert.AreEqual(chats, loaded);
            Debug.WriteLine(string.Format("Saving took {0}; loading took {1}", stopwatch.Elapsed, stopwatch2.Elapsed));
        }
Beispiel #3
0
        /*static void Main()
        {
            Console.WriteLine("Xml Db path?");
            var chats = new XmlChatDatabase(Console.ReadLine()).LoadChats();

            var y = chats.Where(chat => chat.Contact.Contains("cow")).OrderBy(chat => chat.ChatDate);

            var list = new ContactsFactory().GetContacts(new ChatCollection(chats))
                .Select(contact => new { Name = contact.Email, Lines = contact.ChatCollection.Sum(chat => chat.Lines) })
                .OrderByDescending(obj => obj.Lines)
                .Select((obj, rank) => new { obj.Name, obj.Lines, Rank = rank }).ToList();
            var x = list.Single(contact => contact.Name == "cowmaniac95");

            Console.WriteLine(x.Name);
            Console.WriteLine(x.Lines);
            Console.WriteLine(x.Rank);
            Console.ReadLine();

        }*/
        static void Main()
        {
            Console.WriteLine("Downloader output path?");
            var path = Console.ReadLine().Replace("\"", string.Empty);

            var chats = new CsvChatReader(path).GetChatCollection();
            chats = new ChatCollectionCleaner(chats).CleanChats();

            var db = new XmlChatDatabase("chats.xml");
            db.SaveChats(chats);

            var reportPath = Path.Combine(Environment.CurrentDirectory, "Reports");

            var reportManager = new ReportManager(db);
            reportManager.GetReportInstances()
                .ToList()
                .ForEach(report => report.WriteReport(reportPath));
        }