public void TestMethodUpdateUser() { try { var dataStore = new InMemoryDataStore(); var user = new User { UserName = "******" }; int id = dataStore.AddOrUpdateUser(user); Assert.IsTrue(id > 0); var loadUser = dataStore.LoadUser(id); loadUser.UserName = "******"; int newid = dataStore.AddOrUpdateUser(loadUser); var updatedUser = dataStore.LoadUser(newid); Assert.IsTrue(updatedUser.UserId == id && string.Equals(updatedUser.UserName, loadUser.UserName), "Load user is not the same"); } catch (Exception exception) { Debug.WriteLine(format: "Can't update user {0}", args: exception); throw; } }
public void TestMethodAddUserWithEmptyName() { try { var dataStore = new InMemoryDataStore(); var user = new User { UserName = null }; dataStore.AddOrUpdateUser(user); } catch (ArgumentNullException exception) { Assert.IsTrue(string.Equals(exception.Message, "user name can't be null", StringComparison.OrdinalIgnoreCase)); } catch (Exception exception) { Debug.WriteLine(format: "Can't add user {0}", args: exception); throw; } }