Пример #1
0
        public void TestLogIn()
        {
            string user1Name            = "";
            User   user2                = null;
            User   user3                = null;
            User   user4                = null;
            bool   noExceptionWasThrown = true;

            try
            {
                UserProcessor up = new UserProcessor();
                up.InsertNewUser("name", "*****@*****.**", "password");
                up.InsertNewUser("other name", "*****@*****.**", "password");

                User user1 = up.LogInUser("name", "password");
                user2     = up.LogInUser("other name", "password");
                user3     = up.LogInUser("name", "wrong password");
                user4     = up.LogInUser("name", "Password");
                user1Name = user1.UserName;
            }catch (Exception)
            {
                noExceptionWasThrown = false;
            }finally
            {
                //CleanUp
                UserAccess userAccess = new UserAccess();
                userAccess.DeleteByName("name");
                userAccess.DeleteByName("other name");
            }
            Assert.AreEqual("name", user1Name);
            Assert.IsNull(user2);
            Assert.IsNull(user3);
            Assert.IsNull(user4);
            Assert.IsTrue(noExceptionWasThrown);
        }
Пример #2
0
        public void TestGetUserByEmailOrUserName()
        {
            User   user2                = null;
            string user1name            = "";
            User   user4                = null;
            string user3name            = "";
            bool   noExceptionWasThrown = true;

            try
            {
                UserProcessor up = new UserProcessor();
                up.InsertNewUser("name", "*****@*****.**", "password");

                User user1 = up.GetUserByEmail("*****@*****.**");
                user2     = up.GetUserByEmail("asd");
                user1name = user1.UserName;

                User user3 = up.GetUserByUsername("name");
                user4     = up.GetUserByUsername("asd");
                user3name = user3.UserName;
            }catch (Exception)
            {
                noExceptionWasThrown = false;
            }finally
            {
                //CleanUp
                UserAccess userAccess = new UserAccess();
                userAccess.DeleteByName("name");
            }
            Assert.AreEqual("name", user1name);
            Assert.IsNull(user2);
            Assert.AreEqual("name", user3name);
            Assert.IsNull(user4);
            Assert.IsTrue(noExceptionWasThrown);
        }
Пример #3
0
        public void TestInsertApiKey()
        {
            bool   test1 = false;
            bool   test2 = true;
            bool   noExceptionWasThrown = true;
            string apikey = "";

            try
            {
                UserProcessor up = new UserProcessor();
                up.InsertNewUser("name", "*****@*****.**", "password");

                test1 = up.InsertApiKey("*****@*****.**", "key");
                test2 = up.InsertApiKey("Non existing email address", "key");
                User user = up.LogInUser("*****@*****.**", "password");
                apikey = user.ApiKey;
            }catch (Exception)
            {
                noExceptionWasThrown = false;
            }finally
            {
                //CleanUp
                UserAccess userAccess = new UserAccess();
                userAccess.DeleteByName("name");
            }
            Assert.IsTrue(test1);
            Assert.IsFalse(test2);
            Assert.AreEqual("key", apikey);
            Assert.IsTrue(noExceptionWasThrown);
        }