Exemplo n.º 1
0
        public void when_begin_scope_it_should_return_instance_of_scoped_service()
        {
            var adapter = new SimpleInjectorAdapter(MakeContainer());

            using (adapter.BeginScope())
            {
                adapter.GetService(typeof(ScopedService)).Should().BeOfType <ScopedService>("scoped service should be available in a scope");
                adapter.GetService <ScopedService>().Should().BeOfType <ScopedService>("scoped service should be available in a scope");
            }

            Action sut = () => adapter.GetService <ScopedService>();

            sut.Should().ThrowExactly <InvalidOperationException>("scoped service should be unavailable in a scope");
        }