public void RegisterTypeExportTest() { InjectionContext injectionContext = new InjectionContext(null, null); IBasicService testValue = (IBasicService)injectionContext.Locate(typeof(IBasicService)); Assert.Null(testValue); IBasicService newValue = new BasicService(); injectionContext.Export((x, y) => newValue); testValue = (IBasicService)injectionContext.Locate(typeof(IBasicService)); Assert.NotNull(testValue); Assert.True(ReferenceEquals(newValue, testValue)); }
public void LocateUnknownByName() { string exportName = "Test"; InjectionContext injectionContext = new InjectionContext(null, null); injectionContext.Export(exportName, (x, y) => new BasicService()); object testO = injectionContext.Locate("Test2"); Assert.Null(testO); }
public void LocateUnknownType() { InjectionContext injectionContext = new InjectionContext(null, null); IBasicService testValue = (IBasicService)injectionContext.Locate(typeof(IBasicService)); Assert.Null(testValue); IBasicService newValue = new BasicService(); injectionContext.Export((x, y) => newValue); Assert.Null(injectionContext.Locate(typeof(ImportConstructorService))); }
public void LocateByName() { string exportName = "Test"; InjectionContext injectionContext = new InjectionContext(null, null); Assert.Null(injectionContext.Locate(exportName)); injectionContext.Export(exportName, (x, y) => new BasicService()); // I'm getting by to lower because exporting by name is lower case object locatedObject = injectionContext.Locate(exportName.ToLowerInvariant()); Assert.NotNull(locatedObject); }