Exemplo n.º 1
0
        public async Task GetEffectiveUserLicenseAsync_QueryReturnsLicenseType_ReturnsFirst()
        {
            // Arrange
            var cxn         = new SqlConnectionWrapperMock();
            var repository  = new SqlUserRepository(cxn.Object, cxn.Object);
            var userId      = 1;
            var userIds     = new[] { userId };
            var userIdTable = SqlConnectionWrapper.ToDataTable(userIds);
            var result      = new List <UserLicense> {
                new UserLicense {
                    UserId = userId, LicenseType = 3
                }
            };

            cxn.SetupQueryAsync("GetEffectiveUserLicense", new Dictionary <string, object> {
                { "UserIds", userIdTable }
            }, result);

            // Act
            var licenseType = await repository.GetEffectiveUserLicenseAsync(userId);

            // Assert
            cxn.Verify();
            Assert.AreEqual(result.First().LicenseType, licenseType);
        }
Exemplo n.º 2
0
        public async Task GetEffectiveUserLicenseAsync_QueryReturnsEmpty_ReturnsZero()
        {
            // Arrange
            var cxn         = new SqlConnectionWrapperMock();
            var repository  = new SqlUserRepository(cxn.Object, cxn.Object);
            var userId      = 1;
            var userIds     = new[] { userId };
            var userIdTable = SqlConnectionWrapper.ToDataTable(userIds);
            var result      = Enumerable.Empty <UserLicense>();

            cxn.SetupQueryAsync("GetEffectiveUserLicense", new Dictionary <string, object> {
                { "UserIds", userIdTable }
            }, result);

            // Act
            var licenseType = await repository.GetEffectiveUserLicenseAsync(userId);

            // Assert
            cxn.Verify();
            Assert.AreEqual(0, licenseType);
        }