コード例 #1
0
 public PackagesService(IRunAsync powershell, ISourceService sourceService)
 {
     _lines = new List<string>();
     _sourceService = sourceService;
     _libDirHelper = new ChocolateyLibDirHelper();
     _powershellAsync = powershell;
     _powershellAsync.OutputChanged += OutputChanged;
     _powershellAsync.RunFinished += RunFinished;
 }
コード例 #2
0
        public void IfReloadFromDirWithInvalidEnvironmentVariableThenThrowsException()
        {
            var fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
            fileStorageService.Stub(fss => fss.GetDirectories(Arg<string>.Is.Anything)).Throw(new Exception("Posing as HREsult-based exception that environment would throw, per the way the logic is currently written"));
            var helper = new ChocolateyLibDirHelper(MockRepository.GenerateMock<IChocolateyService>(), fileStorageService);

            var result = helper.ReloadFromDir();

            // expects some sort of exception to match current behavior - test should be latered if this behavior is not actually expected :)
        }
コード例 #3
0
        public void IfReloadFromDirWithInvalidDirectoryThenThrowsException()
        {
            var fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
            fileStorageService.Stub(fss => fss.GetDirectories(Arg<string>.Is.Anything)).Throw(new DirectoryNotFoundException());
            var helper = new ChocolateyLibDirHelper(MockRepository.GenerateMock<IChocolateyService>(), fileStorageService);

            var result = helper.ReloadFromDir();

            // expects some sort of exception to match current behavior - test should be latered if this behavior is not actually expected :)
        }
コード例 #4
0
        public void IfReloadFromDirWithEmptyDirectoryThenReturnsListWithChocolatelyOnly()
        {
            var fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
            fileStorageService.Stub(fss => fss.GetDirectories(Arg<string>.Is.Anything)).Return(new string[] { });
            var helper = new ChocolateyLibDirHelper(MockRepository.GenerateMock<IChocolateyService>(), fileStorageService);

            var result = helper.ReloadFromDir();

            Assert.AreEqual("chocolatey", result.Single().Name);
        }
コード例 #5
0
        public void IfReloadFromDirAndHelpTextIsUnrecognizedThenThrowsChocoVersionUnknownException()
        {
            var fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
            fileStorageService.Stub(fss => fss.GetDirectories(Arg<string>.Is.Anything)).Return(new string[] { });
            var chocolatelyService = new FakeChocolateyService() {
                ExpectedOutputFromHelp = "not a valid chocolatey version string"
            };
            var helper = new ChocolateyLibDirHelper(chocolatelyService, fileStorageService);

            var result = helper.ReloadFromDir();

            // expect the version exception
        }
コード例 #6
0
        public void IfReloadFromDirAndHelpTextIsCorrectPatternThenChocolateyPackageContainsProperVersion()
        {
            var fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
            fileStorageService.Stub(fss => fss.GetDirectories(Arg<string>.Is.Anything)).Return(new string[] { });
            var chocolatelyService = new FakeChocolateyService() {
                ExpectedOutputFromHelp = "Version: '0.9.8.20'\nInstall Directory: 'C:\\Chocolatey'"
            };
            var helper = new ChocolateyLibDirHelper(chocolatelyService, fileStorageService);

            var result = helper.ReloadFromDir();

            Assert.AreEqual("0.9.8.20", result.Single().InstalledVersion);
        }
コード例 #7
0
 public ODataPackagesService(ISourceService sourceService, IPackageVersionXMLParser xmlParser)
 {
     _sourceService = sourceService;
     _xmlParser = xmlParser;
     _libDirHelper = new ChocolateyLibDirHelper();
 }
コード例 #8
0
 public ODataPackageVersionService(IPackageVersionXMLParser versionXmlParser, ISourceService sourceService)
 {
     this._versionXmlParser = versionXmlParser;
     this._sourceService = sourceService;
     this._libDirHelper = new ChocolateyLibDirHelper();
 }