상속: IForumService
예제 #1
0
 public void TestMethod1()
 {
     sna = new ServerNetworkAdaptor();
        // Thread t = new Thread(getResult);
        // t.Start();
     Result r = sna.Post("Cars", new Post(new Postkey("dor", DateTime.Now), "Test", "Body", null, "Cars"));
     Console.WriteLine(r.ToString());
 }
예제 #2
0
        public void AddSubforumPersistencyTest()
        {
            string newForumName = "Persistency Test Forum" + DateTime.Now;
            try
            {
                IForumService sc = new ServerNetworkAdaptor();
                sc.Login("admin", "admin");

                Assert.AreEqual(Result.OK, sc.AddSubforum("admin", "admin", newForumName));
            }
            catch (Exception e)
            {
                Console.WriteLine("Got exception while running test: " + e.Message);
                Console.WriteLine(e.InnerException.Message);
                Assert.Fail();
            }

            //ReloadServer();

            string[] subforums;

            try
            {
                IForumService sc = new ServerNetworkAdaptor();
                subforums = sc.GetSubforumsList();
                Assert.True(subforums.Contains<string>(newForumName), "The subforum was not found after reloading DB!");

                Assert.AreEqual(Result.OK, sc.RemoveSubforum("admin", "admin", newForumName), "Could not remove the subforum");

                subforums = sc.GetSubforumsList();
                Assert.False(subforums.Contains<string>(newForumName), "The sub forum was not removed from the DB");
            }
            catch (Exception e)
            {
                Console.WriteLine("Got exception while running test: " + e.Message);
                Console.WriteLine(e.InnerException.Message);
                Assert.Fail();
            }

            //ReloadServer();

            try
            {
                IForumService sc = new ServerNetworkAdaptor();
                subforums = sc.GetSubforumsList();
                Assert.False(subforums.Contains<string>(newForumName), "The subforum exists in DB after reload!!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Got exception while running test: " + e.Message);
                Console.WriteLine(e.InnerException.Message);
                Assert.Fail();
            }
        }
예제 #3
0
 public void AddSubforum()
 {
     ServerNetworkAdaptor target = new ServerNetworkAdaptor(); // TODO: Initialize to an appropriate value
     string adminUsername = "******"; // TODO: Initialize to an appropriate value
     string adminPassword = "******"; // TODO: Initialize to an appropriate value
     string subforumName = "aaaaa"; // TODO: Initialize to an appropriate value
     Result expected = new Result(); // TODO: Initialize to an appropriate value
     Result actual;
     actual = target.AddSubforum(adminUsername, adminPassword, subforumName);
     Assert.AreEqual(expected, actual);
 }
예제 #4
0
        public void PostingPersistencyTest()
        {
            string[] subforums;
            int totalNumOfPosts = 0;
            try
            {
                IForumService sc = new ServerNetworkAdaptor();
                sc.Login("admin", "admin");
                subforums = sc.GetSubforumsList();
                Assert.True(subforums.Length > 0, "No subforums in DB, can't run the test!");

                foreach (string s in subforums)
                {
                    totalNumOfPosts += sc.ReportSubForumTotalPosts("admin", "admin", s);
                }

                Postkey pk = new Postkey("admin", DateTime.Now);
                Post p = new Post(pk, "Persistency Test Post" + DateTime.Now, "Just a random post", null, subforums[0]);
                Assert.AreEqual(Result.OK, sc.Post(subforums[0], p), "Can't post!!! Test failed..");

                Postkey replyKey = new Postkey("admin", DateTime.Now);
                Post reply = new Post(replyKey, "Persistency Test Reply" + DateTime.Now, "Just a random reply", pk, subforums[0]);
                Assert.AreEqual(Result.OK, sc.Reply(pk, reply), "Can't reply!!! Test failed..");
            }
            catch (Exception e)
            {
                Console.WriteLine("Got exception while running test: " + e.Message);
                Console.WriteLine(e.InnerException.Message);
                Assert.Fail();
            }

            //ReloadServer();

            try
            {
                int newNumOfPosts = 0;
                IForumService sc = new ServerNetworkAdaptor();
                sc = new ServerNetworkAdaptor();
                subforums = sc.GetSubforumsList();

                foreach (string s in subforums)
                {
                    newNumOfPosts += sc.ReportSubForumTotalPosts("admin", "admin", s);
                }

                Assert.True(newNumOfPosts - totalNumOfPosts == 1, "Wrong number of posts in DB. expected: " + (totalNumOfPosts + 2) + ", but got: " + newNumOfPosts);

            }
            catch (Exception e)
            {
                Console.WriteLine("Got exception while running test: " + e.Message);
                Console.WriteLine(e.InnerException.Message);
                Assert.Fail();
            }

            //TODO fetch the posts and see they exist.
        }
예제 #5
0
 public void UserPersistencyTest()
 {
     try
     {
         IForumService sc = new ServerNetworkAdaptor();
         sc.Register("persTest", "persTest");
     }
     catch (Exception e)
     {
         Console.WriteLine("Got exception while running test: " + e.Message);
         Console.WriteLine(e.InnerException.Message);
         Assert.Fail();
     }
       //  ReloadServer();
     try
     {
         IForumService sc = new ServerNetworkAdaptor();
         Result r = sc.Login("persTest", "persTest");
         Assert.AreEqual(Result.OK, r, "Tried to login with the user after DB reload, but got " + r.ToString());
     }
     catch (Exception e)
     {
         Console.WriteLine("Got exception while running test: " + e.Message);
         Console.WriteLine(e.InnerException.Message);
         Assert.Fail();
     }
 }