Exemplo n.º 1
0
        public async Task GetLicenseTransactionUserInfoAsync_QueryReturnsUsers_ReturnsUsers()
        {
            // Arrange
            var cxn        = new SqlConnectionWrapperMock();
            var repository = new SqlUserRepository(cxn.Object, cxn.Object);

            int[] userIds     = { 1, 2, 3 };
            var   userIdTable = SqlConnectionWrapper.ToDataTable(userIds);

            LicenseTransactionUser[] result =
            {
                new LicenseTransactionUser {
                    Id = 1, Login = "******", Department = "Dept"
                },
                new LicenseTransactionUser {
                    Id = 2, Login = "******", Department = null
                },
                new LicenseTransactionUser {
                    Id = 3, Login = "******", Department = "Another Dept"
                }
            };
            cxn.SetupQueryAsync("GetLicenseTransactionUser", new Dictionary <string, object> {
                { "UserIds", userIdTable }
            }, result);

            // Act
            IEnumerable <LicenseTransactionUser> users = await repository.GetLicenseTransactionUserInfoAsync(userIds);

            // Assert
            cxn.Verify();
            CollectionAssert.AreEquivalent(result, users.ToList());
        }