public async Task GetLoginUserByIdAsync_QueryReturnsEmpty_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); int userId = 5; LoginUser[] result = { }; cxn.SetupQueryAsync("GetLoginUserById", new Dictionary <string, object> { { "UserId", userId } }, result); // Act LoginUser user = await repository.GetLoginUserByIdAsync(userId); // Assert cxn.Verify(); Assert.IsNull(user); }
public async Task GetLoginUserByIdAsync_QueryReturnsUser_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); int userId = 1; LoginUser[] result = { new LoginUser { Id = userId } }; cxn.SetupQueryAsync("GetLoginUserById", new Dictionary <string, object> { { "UserId", userId } }, result); // Act LoginUser user = await repository.GetLoginUserByIdAsync(userId); // Assert cxn.Verify(); Assert.AreEqual(result.First(), user); }