Blog.Logic.Core.Tests.CommunityLogicTest.ShouldErrorWhenCommunityNameExistsOnUpdate C# (CSharp) Method

ShouldErrorWhenCommunityNameExistsOnUpdate() private method

private ShouldErrorWhenCommunityNameExistsOnUpdate ( ) : void
return void
        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);
        }