예제 #1
0
        public void ShouldThrowExceptionWhenSearchUsersFails()
        {
            _userRepository = new Mock<IUserRepository>();
            _userRepository.Setup(a => a.SearchUsers(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())).Throws(new Exception(""));

            _addressRepository = new Mock<IAddressRepository>();
            _educationRepository = new Mock<IEducationRepository>();
            _mediaRepository = new Mock<IMediaRepository>();

            _usersLogic = new UsersLogic(_userRepository.Object, _addressRepository.Object,
                _educationRepository.Object, _mediaRepository.Object);

            var result = Assert.Throws<BlogException>(() => _usersLogic.SearchUsers("foo", 5, 5));

            Assert.IsInstanceOf(typeof(BlogException), result);
        }
예제 #2
0
        public void ShouldSearchUsers()
        {
            _userRepository = new Mock<IUserRepository>();
            _userRepository.Setup(a => a.SearchUsers(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())).Returns(_users);

            _addressRepository = new Mock<IAddressRepository>();
            _educationRepository = new Mock<IEducationRepository>();
            _mediaRepository = new Mock<IMediaRepository>();

            _usersLogic = new UsersLogic(_userRepository.Object, _addressRepository.Object,
                _educationRepository.Object, _mediaRepository.Object);

            var users = _usersLogic.SearchUsers("foo", 5, 5);

            Assert.NotNull(users);
            Assert.IsInstanceOf(typeof(List<Common.Contracts.User>), users);
        }