public Logic(LazySource <TOut, TMat> stage, TaskCompletionSource <TMat> completion, Attributes inheritedAttributes) : base(stage.Shape) { _stage = stage; _completion = completion; _inheritedAttributes = inheritedAttributes; SetHandler(stage.Out, this); }
static InterceptedQueryProvider() { createLazySource = GenericInvoker .Instance <InterceptedQueryProvider>() .CreateFunc1 <Func <Type, IQueryable>, IQueryable>(x => x.CreateLazySource <object>(null)); queryableExecuteGenericMethod = GenericInvoker .Instance <IQueryProvider>() .CreateFunc1 <Expression, object>(x => x.Execute <object>(null)); }
public void Get() { bool called = false; ISource<int> source = new LazySource<int>(() => { called = true; return 1; }); Assert.False(called); Assert.Equal(1, source.Value); Assert.True(called); }
public void Get() { bool called = false; ISource <int> source = new LazySource <int>(() => { called = true; return(1); }); Assert.False(called); Assert.Equal(1, source.Value); Assert.True(called); }
public void Behavior_Null() { bool called = false; ISource<string> source = new LazySource<string>(LazyBehavior.Null, () => { called = true; return "A"; }); source.Value = null; Assert.Equal("A", source.Value); Assert.True(called); }
public void Behavior_Default() { bool called = false; ISource<int> source = new LazySource<int>(LazyBehavior.Default, () => { called = true; return 1; }); source.Value = 0; Assert.Equal(1, source.Value); Assert.True(called); }
public void Behavior_Default() { bool called = false; ISource <int> source = new LazySource <int>(LazyBehavior.Default, () => { called = true; return(1); }); source.Value = 0; Assert.Equal(1, source.Value); Assert.True(called); }
public void Behavior_Null() { bool called = false; ISource <string> source = new LazySource <string>(LazyBehavior.Null, () => { called = true; return("A"); }); source.Value = null; Assert.Equal("A", source.Value); Assert.True(called); }
public async Task TestExecute() { var lazySource = new Lazy <Entity>(() => new Entity()); var resultPipe = new LazySource <Entity>(() => lazySource.Value, new EmptyServiceProvider()) .ToMockResultPipe(); Assert.False(lazySource.IsValueCreated); var result = await resultPipe.Execute() .GetObjectResultOrDefault <Entity>(); Assert.True(lazySource.IsValueCreated); Assert.Same(lazySource.Value, result); }
public void Get() { ILazySource <IEnumerable <int> > lazySource = new LazySource <IEnumerable <int> >(() => Enumerable.Range(1, 5)); ISource <IEnumerable <int> > source = new EnumerableSource <int>(lazySource); Assert.NotNull(source.Value); Assert.False(lazySource.IsLoaded); source.Value.ForEach(); Assert.True(lazySource.IsLoaded); Assert.True(source.Value.SequenceEqual(lazySource.Value)); }
public void Get() { ILazySource<IEnumerable<int>> lazySource = new LazySource<IEnumerable<int>>(() => Enumerable.Range(1, 5)); ISource<IEnumerable<int>> source = new EnumerableSource<int>(lazySource); Assert.NotNull(source.Value); Assert.False(lazySource.IsLoaded); source.Value.ForEach(); Assert.True(lazySource.IsLoaded); Assert.True(source.Value.SequenceEqual(lazySource.Value)); }
public ContextScopeMediatorBase() { ContextSource = new LazySource <TContext>(LazyBehavior.Null, CreateContext); ContextSource.Loaded += new EventHandler <EventArgs>(ContextSource_Loaded); }
public async Task TestNoChildAttached() { var sourcePipe = new LazySource <Entity>(() => new Entity(), new EmptyServiceProvider()); await Assert.ThrowsAsync <NoPipeAttachedException>(() => ((IOutputPipe <Entity>)sourcePipe).Execute()); }