public void ValidationFailsWhenHarvestingFromCurrentVersionTest()
        {
            TestableValidateHarvestVersionTask task = new TestableValidateHarvestVersionTask()
            {
                BuildEngine       = _engine,
                PackageReportPath = TestReportPath,
                PackageReportFunc = () => new PackageReport()
                {
                    Id      = "TestPackage",
                    Version = "4.6.3",
                    Targets = new Dictionary <string, Target>
                    {
                        {
                            "testTarget", new Target
                            {
                                CompileAssets = new PackageAsset[]
                                {
                                    new PackageAsset {
                                        HarvestedFrom = "TestPackage/4.6.2/ref/netstandard2.0/TestPackage.dll"
                                    }
                                }
                            }
                        }
                    }
                },
                GetLatestStableVersionFunc = (packageId, eraMajor, eraMinor) => string.Empty
            };

            _log.Reset();
            task.Execute();
            Assert.Equal(1, _log.ErrorsLogged);
            Assert.Equal(0, _log.WarningsLogged);
        }
        public void ValidationSucceedsWhenHarvestVersionIsLatestTest()
        {
            TestableValidateHarvestVersionTask task = new TestableValidateHarvestVersionTask()
            {
                BuildEngine                = _engine,
                PackageReportPath          = TestReportPath,
                PackageReportFunc          = () => _testPackageReport,
                GetLatestStableVersionFunc = (packageId, eraMajor, eraMinor) => $"{eraMajor}.{eraMinor}.2"
            };

            _log.Reset();
            task.Execute();
            Assert.Equal(0, _log.ErrorsLogged);
            Assert.Equal(0, _log.WarningsLogged);
        }
示例#3
0
        public void ValidationFailsWhenHarvestVersionIsNotLatestTest()
        {
            TestableValidateHarvestVersionTask task = new TestableValidateHarvestVersionTask()
            {
                BuildEngine                = _engine,
                PackageReports             = _testPackageReportPaths,
                PackageReportFunc          = (path) => _testPackageReport,
                GetLatestStableVersionFunc = (packageId, major, minor) => $"{major}.{minor}.3"
            };

            _log.Reset();
            task.Execute();
            Assert.Equal(1, _log.ErrorsLogged);
            Assert.Equal(0, _log.WarningsLogged);
        }
        public void ValidationSucceedsWhenHarvestVersionIsLatestTest()
        {
            TestableValidateHarvestVersionTask task = new TestableValidateHarvestVersionTask()
            {
                BuildEngine                = _engine,
                PackageReports             = _testPackageReportPaths,
                PackageReportFunc          = (path) => _testPackageReport,
                GetLatestStableVersionFunc = (packageId, major, minor) => $"{major}.{minor}.2"
            };

            _log.Reset();
            task.Execute();
            _log.ErrorsLogged.Should().Be(0);
            _log.WarningsLogged.Should().Be(0);
        }
        public void ValidationSucceedsWhenNoPackagesWhereHarvestedTest()
        {
            TestableValidateHarvestVersionTask task = new TestableValidateHarvestVersionTask()
            {
                BuildEngine       = _engine,
                PackageReportPath = TestReportPath,
                PackageReportFunc = () => new PackageReport()
                {
                    Id      = "TestPackage",
                    Targets = new Dictionary <string, Target>
                    {
                        {
                            "testTarget", new Target
                            {
                                CompileAssets = new PackageAsset[]
                                {
                                    new PackageAsset {
                                    }
                                },
                                RuntimeAssets = new PackageAsset[]
                                {
                                    new PackageAsset {
                                    }
                                },
                                NativeAssets = new PackageAsset[]
                                {
                                    new PackageAsset {
                                    }
                                }
                            }
                        }
                    }
                },
                GetLatestStableVersionFunc = (packageId, eraMajor, eraMinor) => string.Empty
            };

            _log.Reset();
            task.Execute();
            Assert.Equal(0, _log.ErrorsLogged);
            Assert.Equal(0, _log.WarningsLogged);
        }