public void GetComplaintsForProjectReferences_GivenTestProjectFilesDirectory_ExtractsReferencesFromAllGivenFiles()
        {
            var extractorMock = new Mock <IReferencesExtractor>();
            var rulerMock     = new Mock <IReferencesRuler>();
            var runner        = new ReferencesRulerRunner(
                extractor: extractorMock.Object,
                referencesRuler: rulerMock.Object,
                filesRunner: new ProjectFilesRunner(
                    solutionPath: @"../../../TestProjectFiles/",
                    filesExtension: "*.xml"));

            var complaints = runner.GetComplaintsForProjectReferences();

            Assert.True(string.IsNullOrEmpty(complaints));
            extractorMock.Verify(e => e.GetProjectReferences(It.IsAny <string>()), Times.Exactly(7));
        }
        public void GetComplaintsForProjectReferences_RulerHasComplaints_RunnerCollectsThemAll()
        {
            var extractorMock = new Mock <IReferencesExtractor>();

            extractorMock
            .Setup(e => e.GetProjectReferences(It.IsAny <string>()))
            .Returns(new[] { new Reference(from: "source", to: "someReference", isPrivateAssetsAllSet: true, versionOrNull: null), });
            var rulerMock = new Mock <IReferencesRuler>();

            rulerMock
            .Setup(r => r.GiveMeComplaints(It.IsAny <Reference>()))
            .Returns("Aarrr!");
            var runner = new ReferencesRulerRunner(
                extractor: extractorMock.Object,
                referencesRuler: rulerMock.Object,
                filesRunner: new ProjectFilesRunner(
                    solutionPath: @"../../../TestProjectFiles/",
                    filesExtension: "*.xml"));

            var complaints = runner.GetComplaintsForProjectReferences();

            Assert.Equal("Aarrr!\nAarrr!\nAarrr!\nAarrr!\nAarrr!\nAarrr!\nAarrr!", complaints);
        }
        public void GetComplaintsForProjectReferences_RulerHasNoComplaints_ReturnsNoComplaints()
        {
            var extractorMock = new Mock <IReferencesExtractor>();

            extractorMock
            .Setup(e => e.GetProjectReferences(It.IsAny <string>()))
            .Returns(new[] { new Reference(from: "source", to: "someReference", isPrivateAssetsAllSet: true, versionOrNull: null), });
            var rulerMock = new Mock <IReferencesRuler>();

            rulerMock
            .Setup(r => r.GiveMeComplaints(It.IsAny <Reference>()))
            .Returns(string.Empty);
            var runner = new ReferencesRulerRunner(
                extractor: extractorMock.Object,
                referencesRuler: rulerMock.Object,
                filesRunner: new ProjectFilesRunner(
                    solutionPath: @"../../../TestProjectFiles/",
                    filesExtension: "*.xml"));

            var complaints = runner.GetComplaintsForProjectReferences();

            Assert.True(string.IsNullOrEmpty(complaints));
            rulerMock.Verify(e => e.GiveMeComplaints(It.IsAny <Reference>()), Times.Exactly(7));
        }