public void ShouldErrorWhenCommunityNameExistsOnUpdate() { var search = _communities.Where(a => a.Id == 1).ToList(); _communityRepository = new Mock<ICommunityRepository>(); _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), null, null)) .Returns(search); var logic = new CommunityLogic(_communityRepository.Object); var result = logic.Update(new Common.Contracts.Community { Name = "lorem", Description = "fudge brownies" }); Assert.NotNull(result.Error); Assert.AreEqual((int)Constants.Error.ValidationError, result.Error.Id); Assert.AreEqual("Community name lorem is already in use.", result.Error.Message); }
public void ShouldUpdateCommunity() { var community = new Community { Id = 1, Name = "lorem", Description = "fudge brownies" }; _communityRepository = new Mock<ICommunityRepository>(); _communityRepository.Setup(a => a.Edit(It.IsAny<Community>())).Returns(community); _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), null, null)) .Returns(new List<Community>()); var logic = new CommunityLogic(_communityRepository.Object); var result = logic.Update(new Common.Contracts.Community { Id = 1, Name = "lorem", Description = "fudge brownies" }); Assert.NotNull(result); Assert.IsNull(result.Error); }