public override void Context()
            {
               // MockLogger = new MockLogger();
               // Log.InitializeWith(MockLogger);
                configuration.Sources = "https://localhost/somewhere/out/there";
                command = new ChocolateyPinCommand(packageInfoService.Object, nugetLogger.Object, nugetService.Object);

                package = new Mock<IPackage>();
                package.Setup(p => p.Id).Returns("regular");
                package.Setup(p => p.Version).Returns(new SemanticVersion("1.2.0"));
                packageInfoService.Setup(s => s.get_package_information(package.Object)).Returns(new ChocolateyPackageInformation(package.Object) { IsPinned = false });
                pinnedPackage = new Mock<IPackage>();
                pinnedPackage.Setup(p => p.Id).Returns("pinned");
                pinnedPackage.Setup(p => p.Version).Returns(new SemanticVersion("1.1.0"));
                packageInfoService.Setup(s => s.get_package_information(pinnedPackage.Object)).Returns(new ChocolateyPackageInformation(pinnedPackage.Object) { IsPinned = true });
            }
Exemple #2
0
            public override void Context()
            {
                Configuration = Scenario.pin();
                Scenario.reset(Configuration);
                Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
                Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension);
                Scenario.install_package(Configuration, "installpackage", "1.0.0");
                Scenario.install_package(Configuration, "upgradepackage", "1.0.0");
                Scenario.install_package(Configuration, "hasdependency", "1.0.0");

                var commands = NUnitSetup.Container.GetAllInstances<ICommand>();
                Service = commands.Where(
                    (c) =>
                    {
                        var attributes = c.GetType().GetCustomAttributes(typeof(CommandForAttribute), false);
                        return attributes.Cast<CommandForAttribute>().Any(attribute => attribute.CommandName.is_equal_to(Configuration.CommandName));
                    }).FirstOrDefault() as ChocolateyPinCommand;

                Configuration.Sources = ApplicationParameters.PackagesLocation;
                Configuration.ListCommand.LocalOnly = true;
                Configuration.AllVersions = true;
                Configuration.Prerelease = true;
            }