Пример #1
0
        public void nameAcceptTest()
        {
            User newUser = new User();

            newUser.setName("TestName");
            Assert.AreEqual("TestName", newUser.getName());
        }
Пример #2
0
        public CaesuraMain()
        {
            client = new Client.Client();
            server = new Server.Server();
            serverThread = new Thread(new ThreadStart(server.run));
            DatabaseInterface mockDatabase = mocks.Stub<DatabaseInterface>();

            User zarakavaUse = new User();
            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {

                mockDatabase.getUser("Zarakava");
                LastCall.Return(zarakavaUse);
                mockDatabase.getUser("NULLMAN");
                LastCall.Return(null);
            }

            UserRegistration.setDatabase(mockDatabase);

            serverThread.Start();
            System.Threading.Thread.Sleep(5000);
        }
Пример #3
0
        public CaesuraMain()
        {
            client       = new Client.Client();
            server       = new Server.Server();
            serverThread = new Thread(new ThreadStart(server.run));
            DatabaseInterface mockDatabase = mocks.Stub <DatabaseInterface>();

            User zarakavaUse = new User();

            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                mockDatabase.getUser("Zarakava");
                LastCall.Return(zarakavaUse);
                mockDatabase.getUser("NULLMAN");
                LastCall.Return(null);
            }

            UserRegistration.setDatabase(mockDatabase);

            serverThread.Start();
            System.Threading.Thread.Sleep(5000);
        }
Пример #4
0
 public bool login(string userName, string pass)
 {
     if (currentUser == null)
     {
         if (UserRegistration.login(userName, pass))
         {
             currentUser = new User();
             currentUser.setName(userName);
             currentUser.setPass(pass);
             return(true);
         }
         return(false);
     }
     throw new InvalidOperationException("Already Logged in");
 }
Пример #5
0
        public void testIsRegisteredInDatabase()
        {
            DatabaseInterface mockDatabase = mocks.Stub<DatabaseInterface>();

            User zarakavaUse = new User();
            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                mockDatabase.getUser("Zarakava");
                LastCall.Return(zarakavaUse);
                mockDatabase.getUser("NULLMAN");
                LastCall.Return(null);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.isRegistered("Zarakava"));
            Assert.IsFalse(UserRegistration.isRegistered("NULLMAN"));
        }
Пример #6
0
        public void testIsRegisteredInDatabase()
        {
            DatabaseInterface mockDatabase = mocks.Stub <DatabaseInterface>();

            User zarakavaUse = new User();

            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                mockDatabase.getUser("Zarakava");
                LastCall.Return(zarakavaUse);
                mockDatabase.getUser("NULLMAN");
                LastCall.Return(null);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.isRegistered("Zarakava"));
            Assert.IsFalse(UserRegistration.isRegistered("NULLMAN"));
        }
Пример #7
0
        public void testRegisteredInDatabase()
        {
            DatabaseInterface mockDatabase = mocks.Stub <DatabaseInterface>();

            User zarakavaUse = new User();

            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                // The mock will return "Whale Rider" when the call is made with 24
                mockDatabase.registerUser(zarakavaUse);
                LastCall.Return(true);
                mockDatabase.registerUser(null);
                LastCall.Return(false);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.register(zarakavaUse));
            Assert.IsFalse(UserRegistration.register(null));
        }
Пример #8
0
 public bool login(string userName, string pass)
 {
     if (currentUser == null)
     {
         if (UserRegistration.login(userName, pass))
         {
             currentUser = new User();
             currentUser.setName(userName);
             currentUser.setPass(pass);
             return true;
         }
         return false;
     }
     throw new InvalidOperationException("Already Logged in");
 }
Пример #9
0
 public void nullNameTest()
 {
     User newUser = new User();
     newUser.setName(null);
 }
Пример #10
0
 public void nameAcceptTest()
 {
     User newUser = new User();
     newUser.setName("TestName");
     Assert.AreEqual("TestName", newUser.getName());
 }
Пример #11
0
        public void testRegisteredInDatabase()
        {
            DatabaseInterface mockDatabase = mocks.Stub<DatabaseInterface>();

            User zarakavaUse = new User();
            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {

                // The mock will return "Whale Rider" when the call is made with 24
                mockDatabase.registerUser(zarakavaUse);
                LastCall.Return(true);
                mockDatabase.registerUser(null);
                LastCall.Return(false);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.register(zarakavaUse));
            Assert.IsFalse(UserRegistration.register(null));
        }
Пример #12
0
        public void nullNameTest()
        {
            User newUser = new User();

            newUser.setName(null);
        }