public void AreDependenciesRegistered()
        {
            GenerateBuildManifest task = new GenerateBuildManifest();

            var collection = new ServiceCollection();

            task.ConfigureServices(collection);
            var provider = collection.BuildServiceProvider();

            foreach (var dependency in task.GetExecuteParameterTypes())
            {
                var service = provider.GetRequiredService(dependency);
                service.Should().NotBeNull();
            }

            DependencyInjectionValidation.IsDependencyResolutionCoherent(
                s =>
            {
                task.ConfigureServices(s);
            },
                out string message
                )
            .Should()
            .BeTrue(message);
        }
        public void ProducesManifestWithNewPublishingVersion()
        {
            var manifestPath      = Path.Combine("C:", "manifests", "TestManifest.xml");
            var publishingVersion = "3";
            var task = new GenerateBuildManifest
            {
                BuildEngine       = new MockBuildEngine(),
                Artifacts         = new TaskItem[0],
                OutputPath        = manifestPath,
                BuildData         = new string[] { $"InitialAssetsLocation=cloud" },
                PublishingVersion = publishingVersion,
            };

            // Mocks
            Mock <IFileSystem> fileSystemMock   = new Mock <IFileSystem>();
            IList <string>     actualPath       = new List <string>();
            IList <string>     actualBuildModel = new List <string>();

            fileSystemMock.Setup(m => m.WriteToFile(Capture.In(actualPath), Capture.In(actualBuildModel))).Verifiable();

            // Dependency Injection setup
            var collection = new ServiceCollection()
                             .AddSingleton(fileSystemMock.Object)
                             .AddSingleton <IBuildModelFactory, BuildModelFactory>();

            task.ConfigureServices(collection);
            using var provider = collection.BuildServiceProvider();

            // Act and Assert
            task.InvokeExecute(provider).Should().BeTrue();
            actualPath[0].Should().Be(manifestPath);
            actualBuildModel[0].Should().Contain($"PublishingVersion=\"{publishingVersion}\"");
        }
        public void AreDependenciesRegistered()
        {
            GenerateBuildManifest task = new GenerateBuildManifest();

            var collection = new ServiceCollection();

            task.ConfigureServices(collection);
            var provider = collection.BuildServiceProvider();

            DependencyInjectionValidation.IsDependencyResolutionCoherent(
                s =>
            {
                task.ConfigureServices(s);
            },
                out string message,
                additionalSingletonTypes: task.GetExecuteParameterTypes()
                )
            .Should()
            .BeTrue(message);
        }