Post() public méthode

public Post ( string currentSubforum, Post toPost ) : System.Result
currentSubforum string
toPost ForumShared.SharedDataTypes.Post
Résultat System.Result
Exemple #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());
 }
Exemple #2
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.
        }