public void Each_unnecessary_dependency_is_shown_then_they_do_not_match() { // Arrange var nuspecFile = new NuSpecFile { PackageDependencies = new[] { new NuGetPackageDependency{Id = "P1",Version = "v1"}, new NuGetPackageDependency{Id = "P2",Version = "v1"}, new NuGetPackageDependency{Id = "P3",Version = "v2"} } }; var projects = new[] { new Project { PackageDependencies = new[] { new NuGetPackageDependency {Id = "P1", Version = "v1"} } } }; var request = new NuSpecValidationRequest { NuSpecFile = nuspecFile, Projects = projects }; var validator = new NuSpecContainsOnlyRequiredDependenciesValidator(); // Act var results = validator.Validate(request).ToList(); // Assert Assert.That(results.Count, Is.EqualTo(2)); Assert.That(results.First().Message,Is.StringContaining("P2")); Assert.That(results.Last().Message, Is.StringContaining("P3")); }
public void Nothing_is_found_when_dependencies_match() { // Arrange var nuspecFile = new NuSpecFile { PackageDependencies = new[] { new NuGetPackageDependency{Id = "P1",Version = "v1"}, new NuGetPackageDependency{Id = "P2",Version = "v1"} } }; var projects = new[] { new Project { PackageDependencies = new[] { new NuGetPackageDependency {Id = "P1", Version = "v1"}, new NuGetPackageDependency {Id = "P2", Version = "v1"} } } }; var request = new NuSpecValidationRequest { NuSpecFile = nuspecFile, Projects = projects }; var validator = new NuSpecContainsOnlyRequiredDependenciesValidator(); // Act var results = validator.Validate(request).ToList(); // Assert Assert.That(results, Is.Empty); }
public void BeforeAll() { _solutionName = "MySolution.sln"; _fullFilePath = @"C:\where I am\A Solution\MySolution.sln"; _projectOne = Builder<Project>.CreateNew().Build(); _projectTwo = Builder<Project>.CreateNew().Build(); _nuspec1 = Builder<NuSpecFile>.CreateNew().Build(); _nuspec2 = Builder<NuSpecFile>.CreateNew().Build(); var solutionFileContents = GetSolutionFileContents(); var fileSystem = new Mock<IFileSystem>(); fileSystem.Setup(fs => fs.FindFullFilePath(_solutionName)).Returns(_fullFilePath); fileSystem.Setup(fs => fs.ReadFile(_fullFilePath)).Returns(solutionFileContents); fileSystem.Setup(fs => fs.GetDirectory(_fullFilePath)).Returns(""); var projectBuilder = new Mock<IBuilder<Project, BuildProjectRequest>>(); projectBuilder.Setup(b => b.Build(It.Is<BuildProjectRequest>(projectRequest => projectRequest.ProjectFilePath == "Project1\\Project1.csproj"))).Returns(_projectOne); projectBuilder.Setup(b => b.Build(It.Is<BuildProjectRequest>(projectRequest => projectRequest.ProjectFilePath == "Project2\\Project2.csproj"))).Returns(_projectTwo); var nuspecBuilder = new Mock<IBuilder<NuSpecFile, string>>(); nuspecBuilder.Setup(b => b.Build("spec1")).Returns(_nuspec1); nuspecBuilder.Setup(b => b.Build("spec2")).Returns(_nuspec2); var builder = new SolutionBuilder(fileSystem.Object, projectBuilder.Object, nuspecBuilder.Object); var request = new BuildSolutionRequest() .WithSolutionName(_solutionName) .WithNuSpec("spec1") .WithNuSpec("spec2"); _solution = builder.Build(request); }