예제 #1
0
        public void ShouldThrowExceptionWhenGetCreatedCommunityListFails()
        {
            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.GetCreatedCommunitiesByUser(It.IsAny<int>(), It.IsAny<int>()))
                    .Throws(new Exception("Hooha!"));

            var logic = new CommunityLogic(_communityRepository.Object);

            Assert.Throws<BlogException>(() => logic.GetCreatedByUser(1));
        }
예제 #2
0
        public void ShouldGetCreatedCommunityList()
        {
            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.GetCreatedCommunitiesByUser(It.IsAny<int>(), It.IsAny<int>()))
                    .Returns(_communities);
            _communityRepository.Setup(a => a.GetMemberCountByCommunity(It.IsAny<int>())).Returns(5);

            var logic = new CommunityLogic(_communityRepository.Object);
            var result = logic.GetCreatedByUser(1);

            Assert.NotNull(result);
            CollectionAssert.AllItemsAreInstancesOfType(result, typeof(Common.Contracts.Community));
            result.Select(a => a.Posts).ToList().ForEach(Assert.IsNull);
        }