public void current_time() { var now = SystemTime.Default().LocalTime().TimeOfDay; var secondNow = DateTime.Now.TimeOfDay; secondNow.Subtract(now).TotalSeconds.ShouldBeLessThan(1); }
public void local_now() { var now = SystemTime.Default().LocalTime().Time; var secondNow = DateTime.Now; secondNow.Subtract(now).TotalSeconds.ShouldBeLessThan(1); }
public void build_an_object_with_dependencies() { var request = new InMemoryFubuRequest(); var def = new ObjectDef(typeof(FakeJsonBehavior)); def.DependencyByValue(typeof(IFubuRequest), request); var jsonWriter = def.DependencyByType(typeof(IJsonWriter), typeof(AjaxAwareJsonWriter)); jsonWriter.DependencyByType(typeof(IOutputWriter), typeof(OutputWriter)); jsonWriter.DependencyByType(typeof(IRequestData), typeof(InMemoryRequestData)); def.DependencyByType(typeof(IRequestData), typeof(InMemoryRequestData)); var container = new Container(x => { x.For <IFileSystem>().Use <FileSystem>(); x.For <IHttpWriter>().Use <NulloHttpWriter>(); x.For <IActionBehavior>().UseInstance(new ObjectDefInstance(def)); x.For <ILogger>().Use <Logger>(); x.For <ISystemTime>().Use(() => SystemTime.Default()); }); var jsonBehavior = container.GetInstance <IActionBehavior>().ShouldBeOfType <FakeJsonBehavior>(); jsonBehavior.Writer.ShouldBeOfType <AjaxAwareJsonWriter>(); jsonBehavior.Request.ShouldBeTheSameAs(request); }
public void sets_cache_control_to_24_hours_by_default() { var header = new AssetCacheHeaders(SystemTime.Default()).HeadersFor(null).Single(x => x.Name == "Cache-Control"); header.Name.ShouldEqual("Cache-Control"); header.Value.ShouldEqual("private, max-age=86400"); }
public void matches_negative_with_no_execution_time_header() { var systemTime = SystemTime.Default(); var envelope = new Envelope(); var handler = new DelayedEnvelopeHandler(systemTime); envelope.IsDelayed(systemTime.UtcNow()).ShouldBeFalse(); handler.Matches(envelope).ShouldBeFalse(); }
public void configure_a_different_length() { var headers = new AssetCacheHeaders(SystemTime.Default()) { MaxAgeInSeconds = 11111 }; var header = headers.HeadersFor(null).Single(x => x.Name == "Cache-Control"); header.Value.ShouldEqual("private, max-age=11111"); }
public void matches_negative_when_the_execution_time_is_in_the_past() { var systemTime = SystemTime.Default(); var envelope = new Envelope(); envelope.ExecutionTime = systemTime.UtcNow().AddHours(-1); var handler = new DelayedEnvelopeHandler(systemTime); envelope.IsDelayed(systemTime.UtcNow()).ShouldBeFalse(); handler.Matches(envelope).ShouldBeFalse(); }
public void matches_positive() { var systemTime = SystemTime.Default(); var envelope = new Envelope(); envelope.ExecutionTime = systemTime.UtcNow().AddHours(1); var handler = new DelayedEnvelopeHandler(systemTime); envelope.IsDelayed(systemTime.UtcNow()).ShouldBeTrue(); handler.Matches(envelope).ShouldBeTrue(); }
public void stub_then_back_to_live() { var now = DateTime.Today.AddDays(1).AddHours(8); var clock = new Clock(); var systemTime = new SystemTime(clock, new MachineTimeZoneContext()); clock.LocalNow(now); systemTime.LocalTime().Time.ShouldEqual(now); clock.Live(); var firstNow = SystemTime.Default().LocalTime().Time; var secondNow = DateTime.Now; secondNow.Subtract(firstNow).TotalSeconds.ShouldBeLessThan(1); }
public void smoke_test_of_JobTimer_execution() { var now = DateTimeOffset.UtcNow; var ajobTime = now.AddSeconds(50); var bjobTime = now.AddSeconds(25); var cjobTime = now.AddSeconds(10); var timer = new JobTimer(SystemTime.Default(), new RecordingLogger()); timer.Schedule(typeof(AJob), ajobTime, () => Debug.WriteLine("AJob expected at {0} and was at {1}", ajobTime, DateTime.UtcNow)); timer.Schedule(typeof(BJob), bjobTime, () => Debug.WriteLine("BJob expected at {0} and was at {1}", bjobTime, DateTime.UtcNow)); timer.Schedule(typeof(CJob), cjobTime, () => Debug.WriteLine("CJob expected at {0} and was at {1}", cjobTime, DateTime.UtcNow)); timer.WaitForJob(typeof(AJob), 100.Seconds()); timer.WaitForJob(typeof(BJob), 100.Seconds()); timer.WaitForJob(typeof(CJob), 100.Seconds()); }
public PersistenceRegistry() { // This acts as "SetServiceIfNone" For <ISystemTime>().UseIfNone(() => SystemTime.Default()); For <IInitialState>().Add <NulloInitialState>(); For <ITenantContext>().UseIfNone <NulloTenantContext>(); // It's important that these are in this order For <IEntityStoragePolicy>().Add <ByTenantStoragePolicy>(); For <IEntityStoragePolicy>().Add <SoftDeletedStoragePolicy>(); For <IEntityRepository>().Use <EntityRepository>(); For <IStorageFactory>().Use <StorageFactory>(); // Needs to be resolved from the parent ForSingletonOf <ICompleteReset>().Use <CompleteReset>(); For <ILogger>().Use <Logger>(); }
public void execute_sad_path() { var context = new TestContinuationContext(); var envelope = ObjectMother.Envelope(); envelope.ExecutionTime = DateTime.Today; var exception = new NotImplementedException(); envelope.Callback.Stub(x => x.MoveToDelayedUntil(envelope.ExecutionTime.Value)).Throw(exception); new DelayedEnvelopeHandler(SystemTime.Default()).Execute(envelope, context); envelope.Callback.AssertWasCalled(x => x.MarkFailed(exception)); var report = context.RecordedLogs.ErrorMessages.Single().ShouldBeOfType <FubuCore.Logging.ExceptionReport>(); report.CorrelationId.ShouldEqual(envelope.CorrelationId); report.ExceptionText.ShouldEqual(exception.ToString()); }
public void SetUp() { foo1 = new JobStatusDTO { JobKey = "1", NodeName = "foo" }; foo2 = new JobStatusDTO { JobKey = "2", NodeName = "foo" }; foo3 = new JobStatusDTO { JobKey = "3", NodeName = "foo" }; bar1 = new JobStatusDTO { JobKey = "1", NodeName = "bar" }; bar2 = new JobStatusDTO { JobKey = "2", NodeName = "bar" }; thePersistence = new InMemorySchedulePersistence(); thePersistence.Persist(new[] { foo1, foo2, foo3, bar1, bar2 }); theLogger = new RecordingLogger(); theStatusMonitor = new ScheduleStatusMonitor(theChannelGraph, new ScheduledJobGraph(), thePersistence, theLogger, SystemTime.Default()); }
public EntityRepositoryExpression() { UseSystemTime(SystemTime.Default()); BuildWith(basicRepository); }
public void get_today() { SystemTime.Default().LocalTime().Date.Day.ShouldEqual(DateTime.Today); }
public void SetUp() { thePolicy = new SoftDeletedStoragePolicy(SystemTime.Default()); }