Пример #1
0
        public void ShouldThrowExceptionWhenGetUsersByCommunityFails()
        {
            _userRepository = new Mock<IUserRepository>();
            _userRepository.Setup(a => a.GetUsersByCommunity(It.IsAny<int>(), 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 users = Assert.Throws<BlogException>(() => _usersLogic.GetUsersByCommunity(1, 5, 10));

            Assert.IsInstanceOf(typeof(BlogException), users);
        }
Пример #2
0
        public void ShouldGetUsersByCommunitySuccessfully()
        {
            _userRepository = new Mock<IUserRepository>();
            _userRepository.Setup(a => a.GetUsersByCommunity(It.IsAny<int>(), 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.GetUsersByCommunity(1, 5, 10);

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