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"); }
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"); }
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"); }
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(); } }
public void RemoveIgnoreSelf() { 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.RemoveIgnore(testUserModel1); }
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"); }
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)); }
/// <summary> /// This action returns the users email and username to the UserProfile view. /// </summary> /// <returns>The UserProfile view</returns> public ActionResult UserProfile() { CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.Provider.GetUser(User.Identity.Name, true); if (user != null) { ViewData["Email"] = user.Email; ViewData["Name"] = user.UserName; User userModel = user.GetUserModel(); ViewData["JoinDate"] = userModel.Joined; return(View()); } // Ran into an error, redirect to login return(RedirectToAction("Login")); }
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"); }
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."); } }
public void AddBuddyTwice() { 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); testUserModel1.AddBuddy(testUserModel2); }
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"); }