public void UserEngine_DeleteUser() { //Arrange: Seed the Mocked Accessor with a list of Users and creates and 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: Deletes each User from the list of Users using the UserEngine DeleteUser() method int originalSize = mockedUserAccessor.GetState().Count; List <User> results = new List <User>(); for (int i = 0; i < originalSize; i++) { var user = userEngine.DeleteUser(expected.ElementAt(i)); results.Add(user); } //Assert: Checks whether the correct Users were deleted and that the list of Users is empty for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected.ElementAt(i), results.ElementAt(i), $"User {i} was deleted incorrectly."); CollectionAssert.DoesNotContain(mockedUserAccessor.GetState(), expected.ElementAt(i), $"User {i} is still within the list of Users."); } }
public UserEntity DeleteUser(int userId) { try { var user = _userEngine.DeleteUser(userId); if (user == null) { return(null); } RePullUsers(); return(user); } catch (Exception e) { _exceptionHandlerLogic.LogExceptionAsync(e); throw e; } }