public DomainUser GetUser(string userIdentifier) { return(CacheHelper( GetCacheKey(userIdentifier), domainUser => GetCacheKey(domainUser.UserAlias), () => _userEngine.GetUser(userIdentifier), 10)); }
public void UserEngine_GetUser() { //Arrange: Seed Mocked Accessor's list of Users and creates an expected list of Users SeedUsers(); List <User> expected = new List <User> { new User { Id = 1, Email = "*****@*****.**", Password = "******" }, new User { Id = 2, Email = "*****@*****.**", Password = "******" }, new User { Id = 3, Email = "*****@*****.**", Password = "******" } }; //Act: Creates a results list and adds the return User from the UserEngine GetUser() method to the list List <User> results = new List <User>(); for (int i = 1; i <= mockedUserAccessor.GetState().Count; i++) { results.Add(userEngine.GetUser(i)); } //Assert: Checks that each User in the expected and results list are equal for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected.ElementAt(i), results.ElementAt(i), $"User {i} was retrieved incorrectly."); } }
public UserEntity AddUser(UserEntity user) { try { int userId = _userEngine.AddUser(user); user = _userEngine.GetUser(userId); if (user == null) { throw new Exception("Error while writing a new user to DB."); } _userEngine.AddUserToCache(user); return(user); } catch (Exception e) { _exceptionHandlerLogic.LogExceptionAsync(e); throw e; } }