public void IsUsingShouldAddServices()
        {
            MyMvc
            .IsUsingDefaultConfiguration()
            .WithServices(TestObjectFactory.GetCustomServicesRegistrationAction());

            var injectedService        = TestServiceProvider.GetService <IInjectedService>();
            var anotherInjectedService = TestServiceProvider.GetService <IAnotherInjectedService>();

            Assert.NotNull(injectedService);
            Assert.NotNull(anotherInjectedService);

            MyMvc.IsUsingDefaultConfiguration();
        }
Ejemplo n.º 2
0
        public void IsUsingShouldAddServices()
        {
            MyApplication
            .StartsFrom <DefaultStartup>()
            .WithServices(TestObjectFactory.GetCustomServicesRegistrationAction());

            var injectedService        = TestServiceProvider.GetService <IInjectedService>();
            var anotherInjectedService = TestServiceProvider.GetService <IAnotherInjectedService>();

            Assert.NotNull(injectedService);
            Assert.NotNull(anotherInjectedService);

            MyApplication.StartsFrom <DefaultStartup>();
        }
        public void IsUsingShouldRecreateServicesEverytimeItIsInvoked()
        {
            MyMvc.IsUsingDefaultConfiguration();

            var markerService = TestServiceProvider.GetService <MvcMarkerService>();

            Assert.NotNull(markerService);

            MyMvc
            .IsUsingDefaultConfiguration()
            .WithServices(TestObjectFactory.GetCustomServicesRegistrationAction());

            var injectedService        = TestServiceProvider.GetService <IInjectedService>();
            var anotherInjectedService = TestServiceProvider.GetService <IAnotherInjectedService>();

            Assert.NotNull(injectedService);
            Assert.NotNull(anotherInjectedService);

            MyMvc.IsUsingDefaultConfiguration();

            Test.AssertException <NullReferenceException>(
                () =>
            {
                injectedService = TestServiceProvider.GetRequiredService <IInjectedService>();
            },
                "IInjectedService could not be resolved from the services provider. Before running this test case, the service should be registered in the 'StartsFrom' method and cannot be null.");

            MyMvc.IsUsingDefaultConfiguration()
            .WithServices(TestObjectFactory.GetCustomServicesRegistrationAction());

            injectedService        = TestServiceProvider.GetService <IInjectedService>();
            anotherInjectedService = TestServiceProvider.GetService <IAnotherInjectedService>();

            Assert.NotNull(injectedService);
            Assert.NotNull(anotherInjectedService);

            MyMvc.IsUsingDefaultConfiguration();
        }