/// <summary> /// Creates a new instance of this type. /// </summary> public ServiceContainer(RunOptions options) { var services = new ServiceCollection(); services.AddSingleton(options); services.AddSingleton <IProjectAggregator, ProjectAggregator>(); services.AddSingleton <IProjectSearchProvider, ProjectSearchProvider>(); services.AddSingleton(ProjectBuilder.CreateSerializer()); services.AddSingleton <IProjectBuilder, ProjectBuilder>(); services.AddSingleton <IFileSystem, FileSystem>(); services.AddSingleton <IOutputFormatter, OutputFormatter>(); services.AddSingleton <IOptions, OptionsProvider>(); services.AddSingleton(provider => provider.GetService <IFileSystem>().Directory); services.AddSingleton(CreateLogger(options)); if (!options.Tree) { services.AddSingleton <IOutputChannel, DefaultOutputChannel>(); } else { services.AddSingleton <IOutputChannel, TreeOutputChannel>(); } _serviceProvider = services.BuildServiceProvider(); }
public async Task DeserializeFromXmlAsync_Returns_Expected_Values() { var serializer = ProjectBuilder.CreateSerializer(); var subject = new ProjectBuilder(serializer, new FileSystem(), new Mock <ILogger>().Object); var project = await subject.DeserializeFromXmlAsync("Resources/Project.xml"); project.ProjectName.ShouldBe("Project"); project.Path.ShouldBe("Resources/Project.xml"); project.FileName.ShouldBe("Project.xml"); project.Directory.ShouldBe("Resources"); project.GetAssemblyName().ShouldBe("Vertical.Assembly"); project.GetPackageId().ShouldBe("Vertical.Package"); project.GetIsPackable().ShouldBeTrue(); project.Metadata.Sdk.ShouldBe("Microsoft.NET.Sdk"); project.Metadata.ItemGroups[0].Condition.ShouldBe("'$(TargetFramework)'=='.NetCoreApp3.0'"); var packageReferences = project .GetPackageReferences() .Select(reference => (reference.Include, reference.Version)) .ToArray(); packageReferences.ShouldBe(new[]