public async Task GetUser_WeDoNotHaveThisActiveUserInDb_ReturnsNull() { // arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); User[] returnResult = { }; cxn.SetupQueryAsync("GetUserDetails", new Dictionary <string, object> { { "UserId", 0 } }, returnResult); // act var result = await repository.GetUserAsync(0); // assert cxn.Verify(); Assert.IsNull(result); }
public async Task GetUser_WeHaveThisUserInDb_QueryReturnUser() { // arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); var userId = 10; User[] returnResult = { new User { Id = 5 } }; cxn.SetupQueryAsync("GetUserDetails", new Dictionary <string, object> { { "UserId", userId } }, returnResult); // act var result = await repository.GetUserAsync(userId); // assert cxn.Verify(); Assert.AreEqual(returnResult.First(), result); }