Esempio n. 1
0
        public void ShouldLoadSampleModule()
        {
            var map          = new DependencyMap();
            var sampleModule = new SampleModule();
            var loader       = new ModuleLoader(map);

            loader.LoadModule(sampleModule);

            Assert.IsTrue(sampleModule.Invoked);
            Assert.IsTrue(map.Contains(typeof(IList <int>)));
        }
Esempio n. 2
0
        public void Provide_container()
        {
            var module = new SampleModule();

            var container = module.Container(builder =>
            {
                builder.RegisterInstance(Substitute.For <IConvertible>());
                builder.RegisterInstance(Substitute.For <ICustomFormatter>());
            });

            container.Resolve <IDisposable>().Should().NotBeNull();
            container.Resolve <IConvertible>().Should().NotBeNull();
            container.Resolve <ICustomFormatter>().Should().NotBeNull();
        }
Esempio n. 3
0
        public void TestCustomModule()
        {
            SampleModule module = new SampleModule();

            Assert.Equal("Sample", module.Name);
            Assert.Equal("1.0.0.0", module.Version.ToString());

            IServiceCollection services = new ServiceCollection();

            module.ConfigureServices(services, null, null);

            IServiceProvider serviceProvider = services.BuildServiceProvider();
            TestService      testService     = serviceProvider.GetRequiredService <TestService>();

            Assert.Equal(1, testService.TestMethod());
        }
Esempio n. 4
0
        public void Provide_builder()
        {
            var module = new SampleModule();

            var builder = module.Builder();

            ((object)builder).Should().BeOfType <MockContainerBuilder>();

            builder.RegisterInstance(Substitute.For <IComparable>());
            builder.RegisterInstance(Substitute.For <IConvertible>());
            builder.RegisterInstance(Substitute.For <ICustomFormatter>());

            var container = builder.Build();

            container.Resolve <IDisposable>().Should().NotBeNull();
            container.Resolve <IComparable>().Should().NotBeNull();
            container.Resolve <IConvertible>().Should().NotBeNull();
            container.Resolve <ICustomFormatter>().Should().NotBeNull();
        }
Esempio n. 5
0
 static void Main(string[] args)
 {
     var module = new SampleModule();
 }