Remove_WithStringValueRepresentingMultipleHelpParagraphsAndRemoveOptionDistinctOnlyTrue_ShouldNotRemoveMatchingParagraph()
        {
            string matchingParagraph = "JOHNDOE";

            Mock <IMsBuildElementHelpParagraph> paragraphOne = new Mock <IMsBuildElementHelpParagraph>();

            paragraphOne.Setup(p => p.Name).Returns(matchingParagraph);
            Mock <IMsBuildElementHelpParagraph> paragraphTwo = new Mock <IMsBuildElementHelpParagraph>();

            paragraphTwo.Setup(p => p.Name).Returns("NOTRELEVANT");

            IList <IMsBuildElementHelpParagraph> paragraphsList = new List <IMsBuildElementHelpParagraph>()
            {
                paragraphOne.Object,
                paragraphOne.Object,
                paragraphTwo.Object
            };

            MsBuildElementHelp sutHelp = new MsBuildElementHelp(paragraphsList);

            Assert.IsTrue(paragraphsList.Any(p => p.Name.Equals(matchingParagraph)),
                          $"Not altered list should contain item with name '${matchingParagraph}'");

            sutHelp.Remove(matchingParagraph, true);

            Assert.IsTrue(paragraphsList.Any(p => p.Name.Equals(matchingParagraph)),
                          $"After remove item the list should contain a items named '{matchingParagraph}' when remove distinct only is set to false");
        }
        public void Remove_WithStringValueRepresentingOneHelpParagraph_ShouldRemoveMatchingParagraph()
        {
            string matchingParagraph = "JOHNDOE";

            Mock <IMsBuildElementHelpParagraph> paragraphOne = new Mock <IMsBuildElementHelpParagraph>();

            paragraphOne.Setup(p => p.Name).Returns(matchingParagraph);
            Mock <IMsBuildElementHelpParagraph> paragraphTwo = new Mock <IMsBuildElementHelpParagraph>();

            paragraphTwo.Setup(p => p.Name).Returns("NOTRELEVANT");

            IList <IMsBuildElementHelpParagraph> paragraphsList = new List <IMsBuildElementHelpParagraph>()
            {
                paragraphOne.Object,
                paragraphTwo.Object
            };

            MsBuildElementHelp sutHelp = new MsBuildElementHelp(paragraphsList);

            Assert.IsTrue(paragraphsList.Any(p => p.Name.Equals(matchingParagraph)),
                          $"Not altered list should contain item with name '${matchingParagraph}'");

            sutHelp.Remove(matchingParagraph, false);

            Assert.IsFalse(paragraphsList.Any(p => p.Name.Equals(matchingParagraph)),
                           $"After remove item the list should not contain a item named '{matchingParagraph}'");
        }
        public void Remove_ShouldPassThroughInvocationToWrappedImplementation()
        {
            Mock <IMsBuildElementHelpParagraph> itemMock = new Mock <IMsBuildElementHelpParagraph>();

            itemMock.Setup(i => i.Name).Returns("A");

            Mock <IList <IMsBuildElementHelpParagraph> > listMock = new Mock <IList <IMsBuildElementHelpParagraph> >();
            MsBuildElementHelp elementHelp = new MsBuildElementHelp(listMock.Object);

            elementHelp.Remove(itemMock.Object);

            listMock.Verify(l => l.Remove(It.Is <IMsBuildElementHelpParagraph>(i => i.Name.Equals("A"))),
                            Times.Exactly(1));
        }