예제 #1
0
 public void before_all_is_called_before_the_first_context_creation_without_warmup()
 {
     using (var system = new FakeSerenitySystem())
     {
         system.BeforeAllWasCalled.ShouldBe(0);
         system.As<ISystem>().CreateContext();
         system.BeforeAllWasCalled.ShouldBe(1);
     }
 }
예제 #2
0
 public void can_retrieve_services_from_the_serenity_context()
 {
     // just some paranoia here
     using (var system = new FakeSerenitySystem())
     {
         system.As <ISystem>().CreateContext().GetService <FubuRuntime>()
         .ShouldBeTheSameAs(system.Runtime);
     }
 }
예제 #3
0
 public void beforeAll_is_called_as_part_of_warmup()
 {
     using (var system = new FakeSerenitySystem())
     {
         system.BeforeAllWasCalled.ShouldBe(0);
         system.As<ISystem>().Warmup().Wait();
         system.BeforeAllWasCalled.ShouldBe(1);
     }
 }
예제 #4
0
        public void can_create_a_navigation_driver_from_running_serenity_system_with_default_after_navigation()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.As <ISystem>().Warmup().Wait();

                system.Runtime.Get <NavigationDriver>()
                .AfterNavigation.ShouldBeOfType <NulloAfterNavigation>();
            }
        }
예제 #5
0
        public void after_all_is_called_as_the_system_is_disposed_if_the_runtime_has_been_created()
        {
            var system = new FakeSerenitySystem();
            system.As<ISystem>().CreateContext();
            system.AfterAllWasCalled.ShouldBe(0);

            system.SafeDispose();

            system.AfterAllWasCalled.ShouldBe(1);
        }
예제 #6
0
        public void after_all_is_called_as_the_system_is_disposed_if_the_runtime_has_been_created()
        {
            var system = new FakeSerenitySystem();

            system.As <ISystem>().CreateContext();
            system.AfterAllWasCalled.ShouldBe(0);

            system.SafeDispose();

            system.AfterAllWasCalled.ShouldBe(1);
        }
예제 #7
0
        public void before_each_is_called_as_part_of_creating_a_context()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.As <ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(1);

                system.As <ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(2);
                system.As <ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(3);
            }
        }
예제 #8
0
        public void before_all_is_only_called_before_the_first_context_creation()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.BeforeAllWasCalled.ShouldBe(0);
                system.As <ISystem>().CreateContext();
                system.BeforeAllWasCalled.ShouldBe(1);

                system.As <ISystem>().CreateContext();
                system.BeforeAllWasCalled.ShouldBe(1);

                system.As <ISystem>().CreateContext();
                system.BeforeAllWasCalled.ShouldBe(1);

                system.As <ISystem>().CreateContext();
                system.BeforeAllWasCalled.ShouldBe(1);
            }
        }
예제 #9
0
        public void after_each_is_called_as_context_is_finished()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.AfterEachWasCalled.ShouldBe(0);

                var context1 = system.As <ISystem>().CreateContext();
                var scope1   = system.LastScope;

                var specContext = SpecContext.ForTesting();

                context1.AfterExecution(specContext);

                // uses the same scope for the spec
                system.LastScope.ShouldBeTheSameAs(scope1);
                system.LastContext.ShouldBeSameAs(specContext);
                system.AfterEachWasCalled.ShouldBe(1);
            }
        }
예제 #10
0
        public void after_each_is_called_as_context_is_finished()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.AfterEachWasCalled.ShouldBe(0);

                var context1 = system.As<ISystem>().CreateContext();
                var scope1 = system.LastScope;

                var specContext = SpecContext.ForTesting();

                context1.AfterExecution(specContext);

                // uses the same scope for the spec
                system.LastScope.ShouldBeTheSameAs(scope1);
                system.LastContext.ShouldBeSameAs(specContext);
                system.AfterEachWasCalled.ShouldBe(1);
            }
        }
예제 #11
0
        public void each_call_to_before_each_gets_a_new_child_container()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.As <ISystem>().CreateContext();
                var scope1 = system.LastScope;

                system.As <ISystem>().CreateContext();
                var scope2 = system.LastScope;

                system.As <ISystem>().CreateContext();
                var scope3 = system.LastScope;

                scope1.ShouldNotBeTheSameAs(scope2);
                scope1.ShouldNotBeTheSameAs(scope3);
                scope2.ShouldNotBeTheSameAs(scope3);

                scope1.Role.ShouldBe(ContainerRole.ProfileOrChild);
                scope2.Role.ShouldBe(ContainerRole.ProfileOrChild);
                scope3.Role.ShouldBe(ContainerRole.ProfileOrChild);
            }
        }
예제 #12
0
        public void each_call_to_before_each_gets_a_new_child_container()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.As<ISystem>().CreateContext();
                var scope1 = system.LastScope;

                system.As<ISystem>().CreateContext();
                var scope2 = system.LastScope;

                system.As<ISystem>().CreateContext();
                var scope3 = system.LastScope;

                scope1.ShouldNotBeTheSameAs(scope2);
                scope1.ShouldNotBeTheSameAs(scope3);
                scope2.ShouldNotBeTheSameAs(scope3);

                scope1.Role.ShouldBe(ContainerRole.ProfileOrChild);
                scope2.Role.ShouldBe(ContainerRole.ProfileOrChild);
                scope3.Role.ShouldBe(ContainerRole.ProfileOrChild);
            }
        }
예제 #13
0
 public void can_retrieve_services_from_the_serenity_context()
 {
     // just some paranoia here
     using (var system = new FakeSerenitySystem())
     {
         system.As<ISystem>().CreateContext().GetService<FubuRuntime>()
             .ShouldBeTheSameAs(system.Runtime);
     }
 }
예제 #14
0
        public void can_create_a_navigation_driver_from_running_serenity_system_with_provided_after_navigation()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.AfterNavigation<FakeAfterNavigation>();
                system.As<ISystem>().Warmup().Wait();

                system.Runtime.Get<NavigationDriver>()
                    .AfterNavigation.ShouldBeOfType<FakeAfterNavigation>();

            }
        }
예제 #15
0
        public void before_each_is_called_as_part_of_creating_a_context()
        {
            using (var system = new FakeSerenitySystem())
            {
                system.As<ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(1);

                system.As<ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(2);
                system.As<ISystem>().CreateContext();
                system.BeforeEachWasCalled.ShouldBe(3);

            }
        }