コード例 #1
0
        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();
        }
コード例 #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>();
        }
コード例 #3
0
        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();
        }