Beispiel #1
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);
        }
Beispiel #2
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"));
        }
Beispiel #3
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");
 }
Beispiel #4
0
 public void nullPassTest()
 {
     User newUser = new User();
     newUser.setPass(null);
 }
Beispiel #5
0
 public void passAcceptTest()
 {
     User newUser = new User();
     newUser.setPass("TestPass");
     Assert.AreEqual("TestPass", newUser.getPass());
 }
Beispiel #6
0
 public void nullNameTest()
 {
     User newUser = new User();
     newUser.setName(null);
 }
Beispiel #7
0
 public void nameAcceptTest()
 {
     User newUser = new User();
     newUser.setName("TestName");
     Assert.AreEqual("TestName", newUser.getName());
 }
Beispiel #8
0
 public void initializeTest()
 {
     User newUser = new User();
     Assert.IsNotNull(newUser);
 }
Beispiel #9
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));
        }
Beispiel #10
0
 internal static bool register(User toRegister)
 {
     return Database.registerUser(toRegister);
 }