Login() public method

public Login ( String username, String password ) : AuthorizationLevel
username String
password String
return AuthorizationLevel
コード例 #1
0
ファイル: PersistencyTests.cs プロジェクト: sagioto/forum
        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();
            }
        }
コード例 #2
0
ファイル: PersistencyTests.cs プロジェクト: sagioto/forum
        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.
        }
コード例 #3
0
ファイル: PersistencyTests.cs プロジェクト: sagioto/forum
 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();
     }
 }