public async Task ExceptionInDelegateTest() { Task testTask = (await new IxHostBuilder() .Configure( rootNodes => rootNodes .Add <Dummy>( instanceBuilder: new IxClassInstanceBuilderConfig <Dummy>()) .Add <AnotherDummy>( instanceBuilder: IxDelegateInstanceBuilderConfig.New <Dummy, AnotherDummy>( async dummy => { throw new InvalidOperationException("My Error"); }))) .Build()) .AsyncUsing( async host => { using (IxLock <AnotherDummy> anotherDummyLock = await host.Resolver.Get <AnotherDummy>()) { anotherDummyLock.Target.Dummy.Should().NotBeNull(); } }); ((Func <Task>)(async() => await testTask)).ShouldThrow <InvalidOperationException>().WithMessage("My Error"); }
public async Task SimpleTest() { await(await new IxHostBuilder() .Configure( rootNodes => rootNodes .Add <Dummy>( instanceBuilder: new IxClassInstanceBuilderConfig <Dummy>()) .Add <AnotherDummy>( instanceBuilder: IxDelegateInstanceBuilderConfig.New <Dummy, AnotherDummy>( async dummy => new AnotherDummy(dummy)))) .Build()) .AsyncUsing( async host => { using (IxLock <AnotherDummy> anotherDummyLock = await host.Resolver.Get <AnotherDummy>()) { anotherDummyLock.Target.Dummy.Should().NotBeNull(); } }); }