コード例 #1
0
        public void Set(string key, ApplicationInstance item)
        {
            DateTime expiration = _clock.GetCurrentDateTime().AddMinutes(1);

            _context.SetItem(key, item);
            _context.SetCacheItem(key, item, expiration, TimeSpan.Zero);
        }
コード例 #2
0
        public void Certify(Deployment deployment)
        {
            if (deployment != null)
            {
                deployment.CertifiedBy = _securityContext.GetCurrentUsername();
                deployment.CertifiedOn = _clock.GetCurrentDateTime();

                _repository.Save(deployment);
            }
        }
コード例 #3
0
ファイル: DeploymentFactory.cs プロジェクト: mhinze/Tarantino
        public Deployment CreateDeployment(string application, string environment, string deployedBy, string output, string version, bool failed)
        {
            var deployment = new Deployment
            {
                Application = application,
                Environment = environment,
                Version     = version,
                DeployedBy  = deployedBy,
                DeployedOn  = _clock.GetCurrentDateTime(),
                Result      = (failed || (_resultCalculator.GetResult(output) == DeploymentResult.Failure)) ? DeploymentResult.Failure : DeploymentResult.Success
            };

            deployment.SetOutput(new DeploymentOutput {
                Output = output
            });

            return(deployment);
        }
コード例 #4
0
ファイル: DateContextTester.cs プロジェクト: mhinze/Tarantino
        public void Correctly_determines_first_day_of_current_year()
        {
            MockRepository mocks = new MockRepository();
            ISystemClock   clock = mocks.CreateMock <ISystemClock>();

            using (mocks.Record())
            {
                Expect.Call(clock.GetCurrentDateTime()).Return(new DateTime(2007, 4, 15, 8, 15, 0));
            }

            using (mocks.Playback())
            {
                IDateContext context = new DateContext(clock);
                Assert.That(context.GetFirstDayOfCurrentYear(), Is.EqualTo(new DateTime(2007, 1, 1)));
            }

            mocks.VerifyAll();
        }
コード例 #5
0
        public void Correctly_caches_application_instance()
        {
            ApplicationInstance instance = new ApplicationInstance();

            MockRepository mocks   = new MockRepository();
            IWebContext    context = mocks.CreateMock <IWebContext>();
            ISystemClock   clock   = mocks.CreateMock <ISystemClock>();

            using (mocks.Record())
            {
                Expect.Call(clock.GetCurrentDateTime()).Return(new DateTime(2007, 4, 15));
                context.SetItem(ApplicationInstance.CacheKey, instance);
                context.SetCacheItem(ApplicationInstance.CacheKey, instance, new DateTime(2007, 4, 15).AddMinutes(1), TimeSpan.Zero);
            }

            using (mocks.Playback())
            {
                IApplicationInstanceCache cache = new ApplicationInstanceCache(context, clock);
                cache.Set(ApplicationInstance.CacheKey, instance);
            }
        }
コード例 #6
0
ファイル: DateContextTester.cs プロジェクト: mhinze/Tarantino
        public void Correctly_gets_date_by_time_period()
        {
            MockRepository mocks = new MockRepository();
            ISystemClock   clock = mocks.CreateMock <ISystemClock>();

            using (mocks.Record())
            {
                Expect.Call(clock.GetCurrentDateTime()).Return(new DateTime(2007, 4, 15, 8, 15, 0)).Repeat.Times(3);
            }

            using (mocks.Playback())
            {
                IDateContext context = new DateContext(clock);
                Assert.That(context.GetFirstDayOfTimePeriod(TimePeriod.CurrentDay), Is.EqualTo(new DateTime(2007, 4, 15)));
                Assert.That(context.GetFirstDayOfTimePeriod(TimePeriod.CurrentMonth), Is.EqualTo(new DateTime(2007, 4, 1)));
                Assert.That(context.GetFirstDayOfTimePeriod(TimePeriod.CurrentYear), Is.EqualTo(new DateTime(2007, 1, 1)));
                Assert.That(context.GetFirstDayOfTimePeriod(TimePeriod.AllTime), Is.EqualTo(SqlDateTime.MinValue.Value));
            }

            mocks.VerifyAll();
        }
コード例 #7
0
ファイル: DateContextTester.cs プロジェクト: mhinze/Tarantino
        public void Correctly_gets_date_text_by_time_period()
        {
            MockRepository mocks = new MockRepository();
            ISystemClock   clock = mocks.CreateMock <ISystemClock>();

            using (mocks.Record())
            {
                Expect.Call(clock.GetCurrentDateTime()).Return(new DateTime(2007, 4, 15, 8, 15, 0)).Repeat.Times(3);
            }

            using (mocks.Playback())
            {
                IDateContext context = new DateContext(clock);
                Assert.That(context.GetTimePeriodName(TimePeriod.CurrentDay), Is.EqualTo("Today"));
                Assert.That(context.GetTimePeriodName(TimePeriod.CurrentMonth), Is.EqualTo("April, 2007"));
                Assert.That(context.GetTimePeriodName(TimePeriod.CurrentYear), Is.EqualTo("2007"));
                Assert.That(context.GetTimePeriodName(TimePeriod.AllTime), Is.EqualTo("All Time"));
            }

            mocks.VerifyAll();
        }
コード例 #8
0
ファイル: DateContext.cs プロジェクト: mhinze/Tarantino
        public int GetCurrentYear()
        {
            var currentYear = _clock.GetCurrentDateTime().Year;

            return(currentYear);
        }