Exemplo n.º 1
0
 public List <UserEntity> GetAllUsers()
 {
     try {
         var users = _userEngine.GetAllUsersFromCache();
         if (users.Count > 0)
         {
             return(users);
         }
         users = _userEngine.GetAllUsers();
         if (users.Count == 0)
         {
             throw new Exception("No users in DB!");
         }
         Task.Run(() => {
             _userEngine.OverrideUsersCache(users);
         });
         return(users);
     } catch (Exception e) {
         _exceptionHandlerLogic.LogExceptionAsync(e);
         throw e;
     }
 }
        public void UserEngine_GetAllUsers()
        {
            //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: Calls the UserEngine GetAllUsers() method to return all Users
            List <User> results = userEngine.GetAllUsers().ToList();


            //Assert: Checks whether the expected and result lists are exactly the same
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected.ElementAt(i), results.ElementAt(i), $"User {i} was retrieved incorrectly");
            }
        }
Exemplo n.º 3
0
 public IEnumerable <User> GetAllUsers()
 {
     return(_userEngine.GetAllUsers().ToArray());
 }