Esempio n. 1
0
        public void RemoveIgnore()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            CosmoMongerMembershipUser testUser2 = (CosmoMongerMembershipUser)provider.CreateUser("2" + this.baseTestUsername, "test1000", "2" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser2, "Test User 2 was created. status = {0}", new object[] { status });

            User testUserModel2 = testUser2.GetUserModel();

            Assert.IsNotNull(testUserModel2, "Able to get model object for user 2");

            testUserModel1.AddIgnore(testUserModel2);
            testUserModel1.RemoveIgnore(testUserModel2);

            IgnoreList[] antiFriends = testUserModel1.GetIgnoreList();
            Assert.That(antiFriends, Is.Empty, "User 1's ignore list should be empty");
        }
Esempio n. 2
0
        public void AddBuddy()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            CosmoMongerMembershipUser testUser2 = (CosmoMongerMembershipUser)provider.CreateUser("2" + this.baseTestUsername, "test1000", "2" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser2, "Test User 2 was created. status = {0}", new object[] { status });

            User testUserModel2 = testUser2.GetUserModel();

            Assert.IsNotNull(testUserModel2, "Able to get model object for user 2");

            testUserModel1.AddBuddy(testUserModel2);

            BuddyList[] buddies = testUserModel1.GetBuddyList();
            Assert.That(buddies.Where(b => b.FriendId == testUserModel2.UserId), Is.Not.Empty, "User 2 should be User 1's buddy list now");
        }
Esempio n. 3
0
        public void CreatePlayer()
        {
            CosmoMongerDbDataContext db = CosmoManager.GetDbContext();

            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(this.baseTestUsername, "test1000", this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User is created");

            Assert.AreEqual(this.baseTestUsername, testUser.UserName, "Test User has correct username");
            Assert.AreEqual(this.baseTestEmail, testUser.Email, "Test User has correct e-mail");

            testUser = (CosmoMongerMembershipUser)provider.GetUser(this.baseTestUsername, false);
            Assert.IsNotNull(testUser, "Test User exists in the database");
            Assert.AreEqual(this.baseTestUsername, testUser.UserName, "Test User has correct username");
            Assert.AreEqual(this.baseTestEmail, testUser.Email, "Test User has correct e-mail");

            Race humanRace = (from r in db.Races
                              where r.Name == "Human"
                              select r).SingleOrDefault();

            Assert.IsNotNull(humanRace, "Human Race exists in database");

            User testUserModel = testUser.GetUserModel();

            Assert.IsNotNull(testUserModel, "Able to get model object for user");

            Player testPlayer = testUserModel.CreatePlayer(this.baseTestUsername, humanRace);

            Assert.IsNotNull(testPlayer, "Test Player is created");

            Assert.AreEqual(true, testPlayer.Alive, "Test Player is alive");
            Assert.AreEqual(this.baseTestUsername, testPlayer.Name, "Test Player has correct name");
        }
Esempio n. 4
0
        public void Create10000Players()
        {
            string baseEmail            = "*****@*****.**";
            string baseUserName         = "******";
            string basePlayerName       = "stressTestPlayer";
            CosmoMongerDbDataContext db = CosmoManager.GetDbContext();

            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;

            Race skummRace = (from r in db.Races
                              where r.Name == "Skumm"
                              select r).SingleOrDefault();

            for (int i = 0; i < 50000; i++)
            {
                CosmoMongerMembershipUser testUser = (CosmoMongerMembershipUser)provider.CreateUser(i + baseUserName, "test1000", i + baseEmail, null, null, true, null, out status);
                Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

                User testUserModel = testUser.GetUserModel();
                Assert.IsNotNull(testUserModel, "Able to get model object for user");

                Player testPlayer = testUserModel.CreatePlayer(i + basePlayerName, skummRace);
                foreach (Good good in db.Goods)
                {
                    ShipGood shipGood = new ShipGood();
                    shipGood.Ship     = testPlayer.Ship;
                    shipGood.Good     = good;
                    shipGood.Quantity = 0;

                    db.ShipGoods.InsertOnSubmit(shipGood);
                }
                db.SubmitChanges();
            }
        }
Esempio n. 5
0
        public void RemoveIgnoreNotPresent()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            CosmoMongerMembershipUser testUser2 = (CosmoMongerMembershipUser)provider.CreateUser("2" + this.baseTestUsername, "test1000", "2" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser2, "Test User 2 was created. status = {0}", new object[] { status });

            User testUserModel2 = testUser2.GetUserModel();

            Assert.IsNotNull(testUserModel2, "Able to get model object for user 2");

            testUserModel1.RemoveIgnore(testUserModel2);
        }
Esempio n. 6
0
        public void SendMessage()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            CosmoMongerMembershipUser testUser2 = (CosmoMongerMembershipUser)provider.CreateUser("2" + this.baseTestUsername, "test1000", "2" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser2, "Test User 2 was created. status = {0}", new object[] { status });

            User testUserModel2 = testUser2.GetUserModel();

            Assert.IsNotNull(testUserModel2, "Able to get model object for user 2");


            for (int i = 0; i < 10; i++)
            {
                testUserModel1.SendMessage(testUserModel2, "Test Message", "Hello world!");
            }

            IEnumerable <Message> messages = testUserModel1.GetUnreadMessages();

            foreach (Message msg in messages)
            {
                Assert.AreEqual(msg.RecipientUserId, testUserModel1.UserId, "Recipient user should match the user the message is stored under");
                Assert.AreEqual(msg.SenderUserId, testUserModel2.UserId, "Sender user should match the user the message from");
                Assert.AreEqual(msg.Content, "Hello world!", "Message should match what we sent");
                Assert.IsFalse(msg.Received, "This message should not be read yet.");
                msg.MarkAsReceived();
                Assert.IsTrue(msg.Received, "This message should now be read.");
            }
        }
Esempio n. 7
0
        public void AddBuddySelf()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            testUserModel1.AddBuddy(testUserModel1);
        }
Esempio n. 8
0
        public void DeleteUser()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(this.baseTestUsername, "test1000", this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

            // Test the deleting of the user
            bool deleted = provider.DeleteUser(this.baseTestUsername, true);

            Assert.IsTrue(deleted, "The DeleteUser method should have returned true");

            testUser = (CosmoMongerMembershipUser)provider.GetUser(this.baseTestUsername, false);
            Assert.IsNull(testUser, "Test User has been deleted from the database");
        }
Esempio n. 9
0
        public void Ban()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser1 = (CosmoMongerMembershipUser)provider.CreateUser("1" + this.baseTestUsername, "test1000", "1" + this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser1, "Test User 1 was created. status = {0}", new object[] { status });

            User testUserModel1 = testUser1.GetUserModel();

            Assert.IsNotNull(testUserModel1, "Able to get model object for user 1");

            testUserModel1.Ban();

            Assert.That(testUserModel1.Active, Is.False, "User should now be inactive");
        }
Esempio n. 10
0
        private Player CreateTestPlayer(string baseTestUsername, string baseTestEmail, string baseTestPlayerName, Race playerRace)
        {
            CosmoMongerDbDataContext db = CosmoManager.GetDbContext();

            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(baseTestUsername, "test1000", baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

            User testUserModel = testUser.GetUserModel();

            Assert.IsNotNull(testUserModel, "Able to get model object for user");

            return(testUserModel.CreatePlayer(baseTestUsername, playerRace));
        }
Esempio n. 11
0
        public void UpdateProfile1()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(this.baseTestUsername, "test1000", this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

            User testUserModel = testUser.GetUserModel();

            Assert.IsNotNull(testUserModel, "Able to get model object for user");

            // Test the updating of the e-mail
            testUserModel.UpdateEmail("1" + this.baseTestEmail);

            string usernameWithUpdatedEmail = provider.GetUserNameByEmail("1" + this.baseTestEmail);

            Assert.AreEqual(this.baseTestUsername, usernameWithUpdatedEmail, "Test User actually has updated e-mail");
        }
Esempio n. 12
0
        public void DeleteUserLeaveUserData()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(this.baseTestUsername, "test1000", this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

            try
            {
                // Test the deleting of the user
                provider.DeleteUser(this.baseTestUsername, false);
                Assert.Fail("The DeleteUser method should have thrown an exception");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("deleteAllRelatedData", ex.ParamName, "Failed argument should be deleteAllRelatedData.");
            }

            testUser = (CosmoMongerMembershipUser)provider.GetUser(this.baseTestUsername, false);
            Assert.IsNotNull(testUser, "Test User should still be in the database");
        }
Esempio n. 13
0
        public void UpdateProfile2()
        {
            CosmoMongerMembershipProvider provider = new CosmoMongerMembershipProvider();
            MembershipCreateStatus        status;
            CosmoMongerMembershipUser     testUser = (CosmoMongerMembershipUser)provider.CreateUser(this.baseTestUsername, "test1000", this.baseTestEmail, null, null, true, null, out status);

            Assert.IsNotNull(testUser, "Test User was created. status = {0}", new object[] { status });

            User testUserModel = testUser.GetUserModel();

            Assert.IsNotNull(testUserModel, "Able to get model object for user");

            // Change both to something else
            testUserModel.UpdateEmail("1" + this.baseTestEmail);

            // Test updating with the orignal profile values
            testUserModel.UpdateEmail(this.baseTestEmail);

            testUser = (CosmoMongerMembershipUser)provider.GetUser(this.baseTestUsername, false);
            Assert.IsNotNull(testUser, "Reverted Test User exists in the database");
            Assert.AreEqual(this.baseTestUsername, testUser.UserName, "Test User actually has orignal username");
            Assert.AreEqual(this.baseTestEmail, testUser.Email, "Test User actually has orignal e-mail");
        }