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>))); }
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(); }
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()); }
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(); }
static void Main(string[] args) { var module = new SampleModule(); }