public void AutoInjectors_Ctor_Injection_IntgTests() { //arrage Computer pc; //act pc = diCtx.Inject <Desktop>(); //assert Assert.IsInstanceOfType(pc.RAM, typeof(DDRRAM)); Assert.IsNotNull(pc.RAM); Assert.AreEqual(8, pc.RAM.Size); }
public void CurrentNamespace_Class_Injection_IntgTests() { //arrange diCtx.Scan(); //act foo objfoo = diCtx.Inject <foo>(); //assert Assert.IsInstanceOfType(objfoo, typeof(foo)); }
public void CurrentNamespaceRecur_Class_Injection_Ctor_With_Param_IntgTests() { //arrange diCtx.Scan(); //act FakeTypes.For.DITests.foo afoo = diCtx.Inject <FakeTypes.For.DITests.foo>("prop value"); //assert Assert.IsNotNull(afoo); Assert.AreEqual("prop value", afoo.strProp); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Include; options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; }); services.AddSingleton(new VSS.TRex.IO.RecyclableMemoryStreamManager { // Allow up to 256Mb worth of freed small blocks used by the recyclable streams for later reuse // NOte: The default value for this setting is zero which means every block allocated to a // recyclable stream is freed when the stream is disposed. MaximumFreeSmallPoolBytes = 256 * 1024 * 1024 }); //services.AddCommon<Startup>(SERVICE_TITLE, "API for TRex Gateway"); //Set up logging etc. for TRex DIContext.Inject(services.BuildServiceProvider()); services.AddSingleton <IConfigurationStore, GenericConfiguration>(); //Set up configuration for TRex DIContext.Inject(services.BuildServiceProvider()); services.AddSingleton <ICoreXWrapper, CoreXWrapper>(); services.AddSingleton <ITransferProxyFactory>(factory => new TransferProxyFactory(factory.GetRequiredService <IConfigurationStore>(), factory.GetRequiredService <ILoggerFactory>())); TRexGridFactory.AddGridFactoriesToDI(services); Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI(services); DIContext.Inject(services.BuildServiceProvider()); services.AddTransient <ISiteModelMetadata>(factory => new SiteModelMetadata()); services.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()); services.AddTransient <ISiteModels>(factory => SwitchableGridContext.SwitchableSiteModelsContext()); services.AddSingleton <ISiteModelFactory>(new SiteModelFactory()); services.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory()); services.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces.SurveyedSurfaces()); services.AddTransient <IDesigns>(factory => new Designs.Storage.Designs()); services.AddSingleton <ISurveyedSurfaceFactory>(new SurveyedSurfaceFactory()); services.AddSingleton <IMutabilityConverter>(new MutabilityConverter()); services.AddSingleton(new ImmutableClientServer("Webtools-Immutable")); services.AddSingleton(new MutableClientServer("Webtools-Mutable")); // Register the listener for site model attribute change notifications services.AddSingleton <ISiteModelAttributesChangedEventListener>(new SiteModelAttributesChangedEventListener(TRexGrids.ImmutableGridName())); services.AddSingleton <ISiteModelAttributesChangedEventSender>(new SiteModelAttributesChangedEventSender()); services.AddSingleton <IDesignManager>(factory => new DesignManager(StorageMutability.Immutable)); services.AddSingleton <ISurveyedSurfaceManager>(factory => new SurveyedSurfaceManager(StorageMutability.Immutable)); services.AddTransient <IAlignments>(factory => new Alignments.Alignments()); services.AddSingleton <IAlignmentManager>(factory => new AlignmentManager(StorageMutability.Immutable)); services.AddSingleton <ISiteModelMetadataManager>(factory => new SiteModelMetadataManager(StorageMutability.Mutable)); ExistenceMaps.ExistenceMaps.AddExistenceMapFactoriesToDI(services); services.AddSingleton <IExistenceMaps>(factory => new ExistenceMaps.ExistenceMaps()); DIContext.Inject(services.BuildServiceProvider()); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); // Start listening to site model change notifications DIContext.Obtain <ISiteModelAttributesChangedEventListener>().StartListening(); }