Exemplo n.º 1
0
 public void PostToWallTest()
 {
     DataHandler handler = new DataHandler(); //.Instance;
     handler.InsertPerson("Neil");
     handler.InsertPost("Neil","This is my first post");
     Assert.IsTrue(handler.Read("Neil").Count == 1);
 }
Exemplo n.º 2
0
 public void InsertandFindPersonTest()
 {
     DataHandler handler = new DataHandler(); //.Instance;
     handler.InsertPerson("Jai");
     handler.InsertPerson("Neil");
     handler.InsertPerson("Frank");
     handler.InsertPerson("Adrian");
     Assert.IsNotNull(handler.Find("Frank"));
 }
Exemplo n.º 3
0
 public void ReadTest()
 {
     DataHandler handler = new DataHandler(); //.Instance;
     handler.InsertPerson("Neil");
     handler.InsertPost("Neil", "post 1");
     handler.InsertPost("Neil", "post 2");
     handler.InsertPerson("Jai");
     handler.InsertPost("Jai", "This is my first post");
     handler.InsertPost("Neil", "post 3");
     handler.InsertPerson("Ramone");
     handler.InsertPost("Ramone", "This is my first post");
     handler.InsertPost("Neil", "post 5");
     Assert.IsTrue(handler.Read("Neil").Count == 4);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            DataHandler dataHandler = new DataHandler(); //.Instance;
            CommandHandler trendFeed = new CommandHandler();
            bool quit = false;

            trendFeed.Instructions();
            string trendCommand ="";
            while (!quit)
            {
                trendCommand = Console.ReadLine().ToString();
                trendFeed.HandleCommand(trendCommand, dataHandler);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Translates console text into Feed command
        /// </summary>
        /// <param name="trendCommand">console text</param>
        /// <param name="trendFeed">the current feed</param>
        public void HandleCommand(string trendCommand, DataHandler trendFeed)
        {
            if (trendCommand.ToLower().Trim() == "clear")
            {
                Console.Clear();
            }
            else if (trendCommand.IndexOf(" ") == -1)
            {
                List<Post> posts = trendFeed.Read(trendCommand);
                if (posts != null)
                {
                    foreach (Post p in posts)
                    {
                        Console.WriteLine(p.ToTimeLapseString());
                    }
                }
            }
            else if (trendCommand.Contains("->"))
            {
                string[] newTrend = Regex.Split(trendCommand, " -> ");
                try
                {

                    trendFeed.InsertPerson(newTrend[0]);
                    trendFeed.InsertPost(newTrend[0], newTrend[1]);
                }
                catch
                {
                    trendFeed.InsertPost(newTrend[0], newTrend[1]);
                }
            }
            else if (trendCommand.Contains("wall"))
            {
                List<Post> posts = trendFeed.BuildWall(trendCommand.Substring(0, trendCommand.IndexOf(' ')));
                foreach (Post p in posts)
                {
                    Console.WriteLine(p.ToTimeLapseString());
                }

            }
            else if (trendCommand.Contains("follows"))
            {
                trendFeed.Follow(trendCommand.Substring(0, trendCommand.IndexOf(' ')), trendCommand.Substring(trendCommand.LastIndexOf(' ') + 1));
            }
        }
Exemplo n.º 6
0
 public void BuildWallTest()
 {
     DataHandler handler = new DataHandler(); //.Instance;
     handler.InsertPerson("Neil");
     handler.InsertPost("Neil", "This is my first post");
     handler.InsertPost("Neil", "This is my first post");
     handler.InsertPerson("Jai");
     handler.Follow("Neil", "Jai");
     handler.InsertPost("Jai", "This is my first post");
     handler.InsertPost("Neil", "This is my first post");
     handler.InsertPerson("Ramone");
     handler.InsertPost("Ramone", "This is my first post");
     handler.InsertPost("Neil", "This is my first post");
     Assert.IsTrue(handler.Read("Jai").Count == 1);
     Assert.IsTrue(handler.Read("Ramone").Count == 1);
     Assert.IsTrue(handler.BuildWall("Neil").Count == 5);
     Assert.IsTrue(handler.BuildWall("Jai").Count == 1);
 }
Exemplo n.º 7
0
        public void CommandLineTest()
        {
            DataHandler datahandler = new DataHandler(); //.Instance;
            CommandHandler commandHandler = new CommandHandler();

            commandHandler.HandleCommand("Neil -> Post 1", datahandler);
            commandHandler.HandleCommand("Neil -> Post 2", datahandler);
            commandHandler.HandleCommand("Jai -> Post 1", datahandler);
            commandHandler.HandleCommand("Neil -> Post 3", datahandler);
            commandHandler.HandleCommand("Ramone -> Post 1", datahandler);
            commandHandler.HandleCommand("Neil -> Post 4", datahandler);
            commandHandler.HandleCommand("Neil follows Jai", datahandler);
            commandHandler.HandleCommand("Jai -> Post 2", datahandler);
            commandHandler.HandleCommand("Neil -> Post 5", datahandler);
            commandHandler.HandleCommand("Neil -> Post 6", datahandler);
            Assert.IsTrue(datahandler.Read("Neil").Count == 6);
            Assert.IsTrue(datahandler.BuildWall("Neil").Count == 8);
            datahandler.Dispose();
        }