public void SearchNullOrEmptyQueryAccounts(string query)
        {
            // Arrange
            var userService = new Mock <IUserService>();
            var controller  = new DeleteAccountController(userService.Object);

            // Act
            var searchResult = controller.Search(query);

            // Assert
            var data = (List <DeleteAccountSearchResult>)((JsonResult)searchResult).Data;

            Assert.Equal <int>(0, data.Count);
        }
        public void SearchNotExistentUser()
        {
            // Arrange
            User currentUser = null;
            var  userService = new Mock <IUserService>();

            userService.Setup(m => m.FindByUsername(It.IsAny <string>(), false)).Returns(currentUser);
            var controller = new DeleteAccountController(userService.Object);

            // Act
            var searchResult = controller.Search("SomeAccount");

            // Assert
            var data = (List <DeleteAccountSearchResult>)((JsonResult)searchResult).Data;

            Assert.Equal <int>(0, data.Count);
        }
            private List <DeleteAccountSearchResult> SearchAccount(string userName, User findByUsernameResult = null, int findByUsernameTimes = 1)
            {
                // Arrange
                var userService = new Mock <IUserService>();

                userService.Setup(m => m.FindByUsername(It.IsAny <string>(), It.IsAny <bool>()))
                .Returns(findByUsernameResult)
                .Verifiable();

                var controller = new DeleteAccountController(userService.Object);

                // Act
                var result = controller.Search(userName) as JsonResult;

                // Assert
                userService.Verify(m => m.FindByUsername(userName, false), Times.Exactly(findByUsernameTimes));

                Assert.NotNull(result);
                return(result.Data as List <DeleteAccountSearchResult>);
            }
        public void SearchHappyAccont()
        {
            // Arrange
            var userName    = "******";
            var currentUser = new User()
            {
                Username  = userName,
                IsDeleted = false
            };

            var userService = new Mock <IUserService>();

            userService.Setup(m => m.FindByUsername(userName, false)).Returns(currentUser);
            var controller = new DeleteAccountController(userService.Object);

            // Act
            var searchResult = controller.Search(userName);

            // Assert
            var data = (List <DeleteAccountSearchResult>)((JsonResult)searchResult).Data;

            Assert.Equal <int>(1, data.Count);
        }