Exemple #1
0
        public void AddCurrentAssembly_Adds_Resource_Definitions_From_Current_Assembly_To_Container()
        {
            // Arrange
            ServiceDiscoveryFacade facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, NullLoggerFactory.Instance);

            facade.AddCurrentAssembly();

            // Act
            facade.DiscoverInjectables();

            // Assert
            var services = _services.BuildServiceProvider();

            Assert.IsType <TestModelResourceDefinition>(services.GetService <ResourceDefinition <TestModel> >());
        }
Exemple #2
0
        public void DiscoverInjectables_Adds_Resource_Repositories_From_Current_Assembly_To_Container()
        {
            // Arrange
            ServiceDiscoveryFacade facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, _loggerFactory);

            facade.AddCurrentAssembly();

            // Act
            facade.DiscoverInjectables();

            // Assert
            var services = _services.BuildServiceProvider();

            Assert.IsType <TestModelRepository>(services.GetRequiredService <IResourceRepository <TestModel> >());
        }
        public void DiscoverResources_Adds_Resources_From_Current_Assembly_To_Graph()
        {
            // Arrange
            ServiceDiscoveryFacade facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, _loggerFactory);

            facade.AddCurrentAssembly();

            // Act
            facade.DiscoverResources();

            // Assert
            var resourceGraph     = _resourceGraphBuilder.Build();
            var testModelResource = resourceGraph.GetResourceContext(typeof(TestModel));

            Assert.NotNull(testModelResource);
        }
        public void AddCurrentAssembly_Adds_Resource_Hooks_Definitions_From_Current_Assembly_To_Container()
        {
            // Arrange
            ServiceDiscoveryFacade facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, _loggerFactory);

            facade.AddCurrentAssembly();

            _options.EnableResourceHooks = true;

            // Act
            facade.DiscoverInjectables();

            // Assert
            var services = _services.BuildServiceProvider();

            Assert.IsType <TestModelResourceHooksDefinition>(services.GetRequiredService <ResourceHooksDefinition <TestModel> >());
        }
        public void Can_add_resource_service_from_current_assembly_to_container()
        {
            // Arrange
            var facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, _loggerFactory);

            facade.AddCurrentAssembly();

            // Act
            facade.DiscoverInjectables();

            // Assert
            var services = _services.BuildServiceProvider();

            var resourceService = services.GetRequiredService <IResourceService <TestResource> >();

            resourceService.Should().BeOfType <TestResourceService>();
        }
        public void Can_add_resource_from_current_assembly_to_graph()
        {
            // Arrange
            var facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, _loggerFactory);

            facade.AddCurrentAssembly();

            // Act
            facade.DiscoverResources();

            // Assert
            var resourceGraph = _resourceGraphBuilder.Build();

            var resource = resourceGraph.GetResourceContext(typeof(TestResource));

            resource.Should().NotBeNull();
        }
Exemple #7
0
        public void Can_add_resource_hooks_definition_from_current_assembly_to_container()
        {
            // Arrange
            var facade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, LoggerFactory);

            facade.AddCurrentAssembly();

            _options.EnableResourceHooks = true;

            // Act
            facade.DiscoverInjectables();

            // Assert
            var services = _services.BuildServiceProvider();

            var resourceHooksDefinition = services.GetRequiredService <ResourceHooksDefinition <TestResource> >();

            resourceHooksDefinition.Should().BeOfType <TestResourceHooksDefinition>();
        }