예제 #1
0
        public async Task UpdateUserOnInvalidLoginAsync_CallsProcedureWithCorrectParameters()
        {
            // Arrange
            var cxn                 = new SqlConnectionWrapperMock();
            var repository          = new SqlUserRepository(cxn.Object, cxn.Object);
            AuthenticationUser user = new AuthenticationUser
            {
                Login     = "******",
                IsEnabled = true,
                InvalidLogonAttemptsNumber = 1,
                LastInvalidLogonTimeStamp  = new DateTime(0L)
            };

            cxn.SetupExecuteAsync(
                "UpdateUserOnInvalidLogin",
                new Dictionary <string, object>
            {
                { "Login", user.Login },
                { "Enabled", user.IsEnabled },
                { "InvalidLogonAttemptsNumber", user.InvalidLogonAttemptsNumber },
                { "LastInvalidLogonTimeStamp", user.LastInvalidLogonTimeStamp }
            },
                1);

            // Act
            await repository.UpdateUserOnInvalidLoginAsync(user);

            // Assert
            cxn.Verify();
        }
        public async Task PostFile_QueryReturnsId_ReturnsId()
        {
            // Arrange
            var configRepoMock = new Mock <IConfigRepository>();

            configRepoMock.Setup((m) => m.CommandTimeout).Returns(60);
            var  cxn        = new SqlConnectionWrapperMock();
            var  repository = new SqlFilesRepository(cxn.Object, configRepoMock.Object);
            File file       = new File {
                FileName = "name", FileType = "type"
            };
            Guid?result = new Guid("12345678901234567890123456789012");

            cxn.SetupExecuteAsync(
                "[FileStore].InsertFileHead",
                new Dictionary <string, object> {
                { "FileName", file.FileName }, { "FileType", file.FileType }, { "FileId", null }
            },
                1,
                new Dictionary <string, object> {
                { "FileId", result }
            });

            // Act
            Guid?id = await repository.PostFileHead(file);

            // Assert
            cxn.Verify();
            Assert.AreEqual(result, id);
        }
예제 #3
0
        public async Task UpdateUserOnPasswordResetAsync_Success()
        {
            // Arrange
            var cxn        = new SqlConnectionWrapperMock();
            var repository = new SqlUserRepository(cxn.Object, cxn.Object);
            var user       = new AuthenticationUser
            {
                Login    = "******",
                Id       = 99,
                Password = "******",
                UserSalt = new Guid()
            };

            cxn.SetupExecuteAsync(
                "AddCurrentUserPasswordToHistory",
                new Dictionary <string, object>
            {
                { "@userId", user.Id }
            },
                1);

            cxn.SetupExecuteAsync(
                "UpdateUserOnPasswordResetAsync",
                new Dictionary <string, object>
            {
                { "@Login", user.Login },
                { "@Password", user.Password },
                { "@UserSALT", user.UserSalt }
            },
                1);

            // Act
            await repository.UpdateUserOnPasswordResetAsync(user);

            // Assert
            cxn.Verify();
        }
예제 #4
0
        public async Task UpdateUserAsync_SuccessfulUpdateOfUser_ReturnOk()
        {
            // Arrange
            var user = new User
            {
                Login           = "******",
                FirstName       = "FirstNameValueUpdate",
                LastName        = "LastNameValueUpdate",
                DisplayName     = "DisplayNameValueUpdate",
                Email           = "*****@*****.**",
                Source          = UserGroupSource.Database,
                AllowFallback   = false,
                Enabled         = true,
                ExpirePassword  = true,
                Password        = "******",
                UserSALT        = Guid.NewGuid(),
                Title           = "TitleValue",
                Department      = "DepartmentvalueUpdate",
                GroupMembership = new int[] { 1 },
                Guest           = false,
                CurrentVersion  = 1
            };
            var cxn        = new SqlConnectionWrapperMock();
            var repository = new SqlUserRepository(cxn.Object, cxn.Object);
            var errorId    = 1;

            cxn.SetupExecuteAsync("UpdateUser", It.IsAny <Dictionary <string, object> >(), 1, new Dictionary <string, object> {
                { "ErrorCode", errorId }
            });

            // Act
            await repository.UpdateUserAsync(user, null);

            // Assert
            cxn.Verify();
        }