public void Singleton_Test_Success() { // Singleton entities are always the same object var singletonObject = _ep.GetSingleton <IInterfaceModel>(); var singletonSame = EpFactory.GetProvider(Assembly.GetExecutingAssembly().Location, "EntityProvider.Tests").GetSingleton <IInterfaceModel>(); { var singletonObjectIndifferentScope = _ep.GetSingleton <IInterfaceModel>(); // Assert // Singletons of same Assert.Equal(singletonObject, singletonSame); // Singletons gotten in different scopes are the same object Assert.Equal(singletonObject, singletonObjectIndifferentScope); } // EntityProviders must return different singletons from different namespaces var otherEp = EpFactory.GetProvider(Assembly.GetExecutingAssembly().Location, "EntityProvider.Tests.New"); var singletonObjectNew = otherEp.GetSingleton <IInterfaceModel>(); Assert.NotEqual(singletonObject, singletonObjectNew); // Entity providers cannot provide Singletons from Namespaces where there is no imlementation var noImplementationEp = EpFactory.GetProvider(Assembly.GetExecutingAssembly().Location, "EntityProvider.Tests.NotImplementedEntities"); Assert.Throws <NotImplementedException>(() => noImplementationEp.GetSingleton <IInterfaceModel>()); }