Exemplo n.º 1
0
        public void GivenWorkloadsAreOutOfDateUpdatesAreAdvertised()
        {
            _reporter.Clear();
            var testDirectory     = _testAssetsManager.CreateTestDirectory().Path;
            var expectedWorkloads = new List <WorkloadId>()
            {
                new WorkloadId("mock-workload-1"), new WorkloadId("mock-workload-2"), new WorkloadId("mock-workload-3")
            };
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var workloadResolver  = WorkloadResolver.CreateForTests(new MockManifestProvider(new[] { _manifestPath }), new string[] { testDirectory });

            // Lay out fake advertising manifests with pack version update for pack A (in workloads 1 and 3)
            var userHome     = Path.Combine(testDirectory, "userHome");
            var manifestPath = Path.Combine(userHome, ".dotnet", "sdk-advertising", "6.0.100", "SampleManifest", "WorkloadManifest.json");

            Directory.CreateDirectory(Path.GetDirectoryName(manifestPath));
            File.Copy(Path.Combine(_testAssetsManager.GetAndValidateTestProjectDirectory("SampleManifest"), "MockListSampleUpdated.json"), manifestPath);

            var command = new WorkloadListCommand(_parseResult, _reporter, workloadInstaller, "6.0.100", workloadResolver: workloadResolver, userHome: userHome);

            command.Execute();

            // Workloads 1 and 3 should have updates
            _reporter.Lines.Should().Contain(string.Format(LocalizableStrings.WorkloadUpdatesAvailable, "mock-workload-1 mock-workload-3"));
        }
Exemplo n.º 2
0
        public void GivenNoWorkloadsAreInstalledMachineReadableListIsEmpty()
        {
            _reporter.Clear();
            var expectedWorkloads = new List <WorkloadId>();
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var command           = new WorkloadListCommand(_machineReadableParseResult, _reporter, workloadInstaller, "6.0.100");

            command.Execute();

            _reporter.Lines.Should().Contain(l => l.Contains(@"""installed"":[]"));
        }
Exemplo n.º 3
0
        public void GivenNoWorkloadsAreInstalledListIsEmpty()
        {
            _reporter.Clear();
            var expectedWorkloads = new List <WorkloadId>();
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var command           = new WorkloadListCommand(_parseResult, _reporter, workloadInstaller, "6.0.100");

            command.Execute();

            // Expect 3 lines for table headers
            _reporter.Lines.Count.Should().Be(3);
        }
Exemplo n.º 4
0
        public void GivenNoWorkloadsAreInstalledMachineReadableListIsNotEmpty()
        {
            _reporter.Clear();
            var expectedWorkloads = new List <WorkloadId>()
            {
                new WorkloadId("mock-workload-1"), new WorkloadId("mock-workload-2"), new WorkloadId("mock-workload-3")
            };
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var command           = new WorkloadListCommand(_machineReadableParseResult, _reporter, workloadInstaller, "6.0.100");

            command.Execute();

            _reporter.Lines.Should().Contain(l => l.Contains("{\"installed\":[\"mock-workload-1\",\"mock-workload-2\",\"mock-workload-3\"]"));
        }
Exemplo n.º 5
0
        public void GivenNoWorkloadsAreInstalledListIsNotEmpty()
        {
            _reporter.Clear();
            var expectedWorkloads = new List <WorkloadId>()
            {
                new WorkloadId("mock-workload-1"), new WorkloadId("mock-workload-2"), new WorkloadId("mock-workload-3")
            };
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var command           = new WorkloadListCommand(_parseResult, _reporter, workloadInstaller, "6.0.100");

            command.Execute();

            foreach (var workload in expectedWorkloads)
            {
                _reporter.Lines.Should().Contain(workload.ToString());
            }
        }
Exemplo n.º 6
0
        public void GivenNoWorkloadsAreInstalledListIsNotEmpty()
        {
            _reporter.Clear();
            var expectedWorkloads = new List <WorkloadId>()
            {
                new WorkloadId("mock-workload-1"), new WorkloadId("mock-workload-2"), new WorkloadId("mock-workload-3")
            };
            var workloadInstaller = new MockWorkloadRecordRepo(expectedWorkloads);
            var workloadResolver  = WorkloadResolver.CreateForTests(new MockManifestProvider(new[] { _manifestPath }), new string[] { Directory.GetCurrentDirectory() });
            var command           = new WorkloadListCommand(_parseResult, _reporter, workloadInstaller, "6.0.100", workloadResolver: workloadResolver);

            command.Execute();

            foreach (var workload in expectedWorkloads)
            {
                _reporter.Lines.Select(line => line.Trim()).Should().Contain(workload.ToString());
            }
        }