Exemplo n.º 1
0
        public void LogoutTest()
        {
            Task server = runServer();

            server.Start();
            UserCommandManager userCommandManager = new UserCommandManager("127.0.0.1", 5555);

            Assert.IsTrue(userCommandManager.Login("admin", "Qwerty123"));
            Assert.IsTrue(userCommandManager.Logout());
            userCommandManager.Exit();
            server.Wait();
        }
Exemplo n.º 2
0
        public void MessageTest()
        {
            Task server = runServer();

            server.Start();
            UserCommandManager userCommandManager = new UserCommandManager("127.0.0.1", 5555);

            Assert.IsTrue(userCommandManager.Login("user", "Qwerty123"));
            Assert.IsTrue(userCommandManager.SendMessage("guest", "Test"));
            Assert.IsTrue(userCommandManager.Logout());
            Assert.IsTrue(userCommandManager.Login("guest", "Qwerty123"));
            string messages = userCommandManager.ReadMessage().Trim();

            Assert.IsTrue(userCommandManager.Error == "");
            string[] data = messages.Split(';');
            Assert.IsTrue(data.Length == 4);
            userCommandManager.Exit();
            server.Wait();
        }
Exemplo n.º 3
0
        public void RecoveryAndChangeQuestionTest()
        {
            Task server = runServer();

            server.Start();
            UserCommandManager userCommandManager = new UserCommandManager("127.0.0.1", 5555);
            string             newquestion = "Ala ma ...", newanswer = "kota";

            Assert.IsTrue(userCommandManager.Login("user", "Qwerty123"));
            Assert.IsTrue(userCommandManager.ChangeQuestion(newquestion, newanswer));
            Assert.IsTrue(userCommandManager.Logout());
            string question = userCommandManager.Recovery("user");

            Assert.IsTrue(userCommandManager.Error == "");
            string password = userCommandManager.Answer("user", "kota");

            Assert.IsTrue(userCommandManager.Error == "");
            Assert.IsTrue(userCommandManager.Login("user", password), password);
            userCommandManager.Exit();
            server.Wait();
        }
Exemplo n.º 4
0
        public void ChangePasswordTest()
        {
            Task server = runServer();

            server.Start();
            UserCommandManager userCommandManager = new UserCommandManager("127.0.0.1", 5555);
            string             newpassword        = "******";

            Assert.IsFalse(userCommandManager.ChangePassword(newpassword));
            Assert.IsTrue(userCommandManager.Login("user", "Qwerty123"), userCommandManager.Error);
            Assert.IsTrue(userCommandManager.ChangePassword(newpassword));
            Assert.IsTrue(userCommandManager.Logout(), userCommandManager.Error);
            Assert.IsTrue(userCommandManager.Login("user", newpassword));
            userCommandManager.Exit();
            server.Wait();

            Task textserver = runServer();

            textserver.Start();

            TcpClient     tcpClient = new TcpClient("127.0.0.1", 5555);
            StreamManager sm        = new StreamManager(tcpClient.GetStream());

            sm.Data = $"changepassword;{newpassword}";
            Assert.AreNotEqual(sm.Data, "passwordchanged");
            sm.Data = "login;user;Qwerty123";
            Assert.AreEqual(sm.Data, "loged");
            sm.Data = $"changepassword;{newpassword}";
            Assert.AreEqual(sm.Data, "passwordchanged");
            sm.Data = "logout";
            Assert.AreEqual(sm.Data, "logout");
            sm.Data = $"login;user;{newpassword}";
            Assert.AreEqual(sm.Data, "loged");
            sm.Data = "exit";

            textserver.Wait();
        }