Beispiel #1
0
        public void Initialize()
        {
            //Need to setup the logger first
            if (LoggingEnabled)
                LoggerProvider = Options.LoggerProvider ?? new SystemLoggerProviderLog4Net(this);

            _logger = LoggerProvider.CreateLogger(typeof(Settings));

            //Setting up the rest of the system
            _logger.Info("Settings - Setup Started");
            _logger.Debug(() => string.Format("Settings - Settings Extension Options - {0}", Options));

            var sqlFactory = new SqlFactory();

            var feedProvider = new NugetReleaseFeedProvider();
            var persistencyProvider = new ReleasePersistencyProvider(sqlFactory);
 
            QueryProvider = new CacheReleaseQueryProvider();

            ExistingReleaseService = new ExistingReleaseQueryService(QueryProvider);
            NewReleaseService = new NewReleaseQueryService(QueryProvider);
            UpdateReleaseRepositoryService = new UpdateReleaseRepositoryService(feedProvider, persistencyProvider);
            UpdateReleaseService = new UpdateReleaseService(this, UpdateReleaseRepositoryService, QueryProvider);
            ReleaseService = new ReleaseService(QueryProvider);

            _logger.Info("Settings - Setup Finished");

            //Run system setup
            _logger.Info("Settings - Pre Initialize");
             
            UpdateReleaseService.Execute(true);

            _logger.Info("Settings - Post Initialize");
        }
            public void ShouldReturnEmptyIsNoMatchFound()
            {
                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns((ReleaseQueryItem)null).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo("Test", "1.0");

                Assert.False(result.HasResult);
                Assert.False(result.HasNewer);
                Assert.Null(result.Summary);
                Assert.Null(result.Releases);

                repository.VerifyAll();
            }
            public void ShouldIndicateThatNoNewerVersionIsFoundIfOneDoesntExist()
            {
                var release = new ReleaseQueryItem { IsLatestVersion = true };

                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns(release).Verifiable();
                repository.Setup(x => x.FindReleasesAfter("Test", "1.0")).Returns(new List<ReleaseQueryItem>()).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo("Test", "1.0");

                Assert.True(result.HasResult);
                Assert.False(result.HasNewer);
                Assert.Null(result.Summary);
                Assert.Null(result.Releases);

                repository.VerifyAll();
            }
            public void ShouldProduceReleaseSummaryWhenOnlyNewerReleasesFound()
            {
                var release = new ReleaseQueryItem { IsLatestVersion = false, Created = new DateTime(2012, 12, 12), Version = "1.0" };
                var release1 = new ReleaseQueryItem { IsLatestVersion = false, Created = new DateTime(2012, 12, 13), Version = "1.1" };
                var release2 = new ReleaseQueryItem { IsLatestVersion = false, Created = new DateTime(2012, 12, 14), Version = "1.2" };
                var release3 = new ReleaseQueryItem { IsLatestVersion = true, Created = new DateTime(2012, 12, 15), Version = "1.3" };

                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns(release).Verifiable();
                repository.Setup(x => x.FindReleasesAfter("Test", "1.0")).Returns(new List<ReleaseQueryItem> { release1, release2, release3 }).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo("Test", "1.0");

                Assert.True(result.HasResult);
                Assert.True(result.HasNewer);
                Assert.NotNull(result.Summary);
                Assert.True(result.Summary.ContainsKey("release"));
                Assert.Equal("1.3", result.Summary["release"].LatestVersion);
                Assert.False(result.Summary.ContainsKey("preRelease"));
                Assert.Null(result.Releases);

                repository.VerifyAll();
            }
            public void ShoudlIndicateHasNewerWhenAnyPackageHasNewer()
            {
                var release = new ReleaseQueryItem { IsLatestVersion = false, Created = new DateTime(2012, 12, 12), Version = "1.0" };
                var release1 = new ReleaseQueryItem { IsLatestVersion = true, Created = new DateTime(2012, 12, 13), Version = "1.1" };

                var input1 = new VersionCheckDetailsItem() { Name = "Test", Version = "1.0" };
                var input2 = new VersionCheckDetailsItem() { Name = "Other", Version = "1.0" };
                var input = new VersionCheckDetails { Packages = new List<VersionCheckDetailsItem> { input1, input2 } };

                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns(release).Verifiable();
                repository.Setup(x => x.SelectRelease("Other", "1.0")).Returns((ReleaseQueryItem)null).Verifiable();
                repository.Setup(x => x.FindReleasesAfter("Test", "1.0")).Returns(new List<ReleaseQueryItem> { release1 }).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo(input);

                Assert.Equal(2, result.Details.Count);
                Assert.True(result.Details.ContainsKey("Test"));
                Assert.True(result.Details["Test"].HasNewer);
                Assert.True(result.Details["Test"].HasResult);
                Assert.True(result.Details.ContainsKey("Other"));
                Assert.False(result.Details["Other"].HasNewer);
                Assert.False(result.Details["Other"].HasResult);
                Assert.True(result.HasNewer);

                repository.VerifyAll();
            }
            public void ShouldBeAbleToUseCollectiontOverload()
            {
                var input1 = new VersionCheckDetailsItem() { Name = "Test", Version = "1.0" };
                var input2 = new VersionCheckDetailsItem() { Name = "Other", Version = "1.0" };
                var input = new VersionCheckDetails {Packages = new List<VersionCheckDetailsItem> {input1, input2}};

                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns((ReleaseQueryItem)null).Verifiable();
                repository.Setup(x => x.SelectRelease("Other", "1.0")).Returns((ReleaseQueryItem)null).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo(input);

                Assert.Equal(2, result.Details.Count);
                Assert.True(result.Details.ContainsKey("Test"));
                Assert.True(result.Details.ContainsKey("Other")); 
                Assert.False(result.HasNewer);

                repository.VerifyAll();
            }
            public void ShouldBeAbleToUseObjectOverload()
            {
                var input = new VersionCheckDetailsItem() {Name = "Test", Version = "1.0"};

                var repository = new Mock<IReleaseQueryProvider>();
                repository.Setup(x => x.SelectRelease("Test", "1.0")).Returns((ReleaseQueryItem)null).Verifiable();

                var service = new NewReleaseQueryService(repository.Object);
                var result = service.GetLatestReleaseInfo(input);

                Assert.False(result.HasResult);
                Assert.False(result.HasNewer);
                Assert.Null(result.Summary);
                Assert.Null(result.Releases);

                repository.VerifyAll();
            }