예제 #1
0
        private void GetClass_InjectAsWithMatchingOverride()
        {
            // act
            serviceCollection.ResolveDependencies(o => { o.UseOverride("myOverride"); });
            serviceProvider = serviceCollection.BuildServiceProvider();

            IServiceToRegister  service            = serviceProvider.GetService <IServiceToRegister>();
            IServiceNotRegister serviceNotExpected = serviceProvider.GetService <IServiceNotRegister>();

            // assert
            service.Should().NotBeNull().And.BeOfType <InjectAsOverrideClass>();
            serviceNotExpected.Should().BeNull();
        }
        private void GetClass_WithSpecificService()
        {
            // act
            serviceCollection.ResolveDependencies();
            serviceProvider = serviceCollection.BuildServiceProvider();

            IServiceToRegister  service            = serviceProvider.GetService <IServiceToRegister>();
            IServiceNotRegister serviceNotExpected = serviceProvider.GetService <IServiceNotRegister>();

            // assert
            service.Should().NotBeNull().And.BeOfType <ClassWithSpecificService>();
            serviceNotExpected.Should().BeNull();
        }