public void GetUsersWithData() { IUsersStorageProviderV40 prov = GetProvider(); UserInfo user1 = prov.AddUser("user1", "User1", "password", "*****@*****.**", true, DateTime.UtcNow); UserInfo user2 = prov.AddUser("user2", "User2", "password", "*****@*****.**", true, DateTime.UtcNow); UserInfo user3 = prov.AddUser("user3", "User3", "password", "*****@*****.**", true, DateTime.UtcNow); UserInfo user4 = prov.AddUser("user4", "User4", "password", "*****@*****.**", true, DateTime.UtcNow); Assert.AreEqual(0, prov.GetUsersWithData("Key").Count, "Wrong user count"); prov.StoreUserData(user1, "Key", "Value"); prov.StoreUserData(user2, "Key2", "Value"); prov.StoreUserData(user4, "Key", "Value2"); IDictionary <UserInfo, string> data = prov.GetUsersWithData("Key"); Assert.AreEqual(2, data.Count, "Wrong user count"); UserInfo[] users = new UserInfo[data.Count]; data.Keys.CopyTo(users, 0); AssertUserInfosAreEqual(user1, users[0], true); AssertUserInfosAreEqual(user4, users[1], true); Assert.AreEqual("Value", data[users[0]], "Wrong data"); Assert.AreEqual("Value2", data[users[1]], "Wrong data"); }
public void StoreUserData_RetrieveUserData_Overwrite() { IUsersStorageProviderV40 prov = GetProvider(); UserInfo user = prov.AddUser("User", "User", "password", "*****@*****.**", true, DateTime.Now); Assert.IsTrue(prov.StoreUserData(user, "Key", "Value1"), "StoreUserData should return true"); Assert.IsTrue(prov.StoreUserData(user, "Key2", "Value2"), "StoreUserData should return true"); Assert.IsTrue(prov.StoreUserData(user, "Key", "Value"), "StoreUserData should return true"); string value = prov.RetrieveUserData(user, "Key"); Assert.AreEqual("Value", value, "Wrong value"); string value2 = prov.RetrieveUserData(user, "Key2"); Assert.AreEqual("Value2", value2, "Wrong value"); }
public void StoreUserData_InvalidKey(string k) { IUsersStorageProviderV40 prov = GetProvider(); UserInfo user = new UserInfo("User", "User", "*****@*****.**", true, DateTime.Now, prov); prov.StoreUserData(user, k, "Value"); }
public void RetrieveAllUserData() { IUsersStorageProviderV40 prov = GetProvider(); Assert.AreEqual(0, prov.RetrieveAllUserData(new UserInfo("Inexistent", "Inex", "*****@*****.**", true, DateTime.Now, prov)).Count, "Wrong data count"); UserInfo user1 = prov.AddUser("user1", "User1", "password", "*****@*****.**", true, DateTime.Now); UserInfo user2 = prov.AddUser("user2", "User2", "password", "*****@*****.**", true, DateTime.Now); Assert.AreEqual(0, prov.RetrieveAllUserData(user1).Count, "Wrong data count"); prov.StoreUserData(user1, "Key", "Value"); prov.StoreUserData(user1, "Key2", "Value2"); prov.StoreUserData(user2, "Key", "Value3"); IDictionary <string, string> data = prov.RetrieveAllUserData(user1); Assert.AreEqual(2, data.Count, "Wrong data count"); Assert.AreEqual("Value", data["Key"], "Wrong data"); Assert.AreEqual("Value2", data["Key2"], "Wrong data"); }
public void StoreUserData_NullUser() { IUsersStorageProviderV40 prov = GetProvider(); prov.StoreUserData(null, "Key", "Value"); }