Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }