public void RemovesAllRegisteredServices()
        {
            var locator = new ServiceLocator();
            var service = new SimpleService();
            var defaultNumberOfSerices = locator.Count;

            locator.Register(Guid.NewGuid(), service);
            locator.Register(new[] { typeof(ITestService), typeof(SimpleService) }, service);
            locator.Register(new[] { "Service1", "Service2" }, service);
            locator.Register(Guid.NewGuid(), ServiceMode.Clone, (sender, e) => { e.Service = new SimpleService(); });
            locator.Register(1u, service);
            locator.Register("Serice3", typeof(SimpleService), ServiceMode.Clone);

            Assert.AreNotEqual(0, locator.Count);
            Assert.AreEqual(8 + defaultNumberOfSerices, locator.Count);

            locator.Clear();
            Assert.AreEqual(defaultNumberOfSerices, locator.Count);

            var newService = locator.GetService(typeof(SimpleService));

            Assert.IsNotNull(newService);

            newService = locator.GetService(1u);
            Assert.IsNull(newService);

            newService = locator.GetService("Service1");
            Assert.IsNull(newService);
        }
 public void TestInit()
 {
     configurationService.Clear();
     serviceLocator = ServiceLocator.GetInstance();
     ServiceLocator.Clear();
     MockListItemRepository.Clear();
 }
 public void TestInit()
 {
     ServiceLocator.Clear();
     MockTrainingCourseRepository.Clear();
     MockRegistrationRepository.Clear();
     MockRegistrationApprovalTaskRepository.Clear();
 }
Exemplo n.º 4
0
 private static void LoadGame()
 {
     Time.timeScale = 1;
     ServiceLocator.Clear();
     SceneManager.LoadScene(SceneName);
     SceneManager.LoadScene(InstanceScene, LoadSceneMode.Additive);
 }
Exemplo n.º 5
0
 public void TestClear()
 {
     ServiceLocator.Register(1);
     Assert.AreEqual(1, ServiceLocator.Locate <int>());
     ServiceLocator.Clear();
     ServiceLocator.Locate <int>();
 }
Exemplo n.º 6
0
 public void RegisterServiceOfExistingType()
 {
     ServiceLocator.Clear();
     serviceLocator.Register <ITestInterface>(typeof(TestInstance));
     serviceLocator.Register <ITestInterface>(typeof(TestInstanceThree));
     Assert.AreEqual(1, serviceLocator.Count);
     Assert.IsInstanceOfType(serviceLocator.Get <ITestInterface>(), typeof(TestInstanceThree));
 }
Exemplo n.º 7
0
 public void TearDown()
 {
     ServiceLocator.Clear();
     if (Directory.Exists(_stageFolderPath))
     {
         Directory.Delete(_stageFolderPath, true);
     }
 }
Exemplo n.º 8
0
        public void TestClearInternalCash()
        {
            var instance1 = ServiceLocator.Get <TestClass>();

            ServiceLocator.Clear();
            var instance2 = ServiceLocator.Get <TestClass>();

            Assert.AreNotSame(instance1, instance2);
        }
        public void TestInit()
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                web = site.AllWebs.Add(Guid.NewGuid().ToString(), "", "", 1033, "CONTOSOTRAINING#0", false, false);
            }

            ServiceLocator.Clear();
            mockView = new MockDirectReportsView();
        }
Exemplo n.º 10
0
        public void TestInit()
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                web = site.AllWebs.Add(Guid.NewGuid().ToString(), "", "", 1033, "CONTOSOTRAINING#0", false, false);
            }

            ServiceLocator.Clear();
            MockRegistrationRepository.Clear();
        }
Exemplo n.º 11
0
        public void TestClearPresetInstance()
        {
            var presetInstance = new TestClass();

            ServiceLocator.Set(presetInstance);
            ServiceLocator.Clear();
            var instance = ServiceLocator.Get <TestClass>();

            Assert.AreNotSame(presetInstance, instance);
        }
Exemplo n.º 12
0
        public void TestClearAndHas()
        {
            ServiceLocator.Register <IServiceTestAAA>(new ServiceTestAAA());
            ServiceLocator.Register <IServiceTestCCC>(new ServiceTestCCC());
            ServiceLocator.Clear();
            IsFalse(ServiceLocator.Has <IServiceTestAAA>());
            IsFalse(ServiceLocator.Has <IServiceTestBBB>());
            IsFalse(ServiceLocator.Has <IServiceTestCCC>());

            ServiceLocator.Register <IServiceTestCCC>(new ServiceTestCCC());
            IsTrue(ServiceLocator.Has <IServiceTestCCC>());
        }
Exemplo n.º 13
0
        public void CheckIfClearPreservesDefaultSetOfServices()
        {
            var locator = new ServiceLocator();
            var defaultNumberOfServices = locator.Count;

            Assert.AreNotEqual(0, defaultNumberOfServices);

            locator.Register(1u, new SimpleService());
            Assert.AreNotEqual(defaultNumberOfServices, locator.Count);

            locator.Clear();
            Assert.AreEqual(defaultNumberOfServices, locator.Count);
        }
        public void TestInit()
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                web      = site.AllWebs.Add(Guid.NewGuid().ToString(), "", "", 1033, "CONTOSOTRAINING#0", false, false);
                userName = web.SiteUsers.GetByID(1).Name;
            }

            ServiceLocator.Clear();
            MockTrainingCourseRepository.Clear();
            MockRegistrationRepository.Clear();
            MockRegistrationApprovalTaskRepository.Clear();
        }
Exemplo n.º 15
0
 public visual_studio()
 {
     ServiceLocator.Clear();
     Vs2010Path = (string)Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0\Setup\VS\").GetValue("EnvironmentDirectory") + "devenv.com";
     Vs2008Path = (string)Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0\Setup\VS\").GetValue("EnvironmentDirectory") + "devenv.com";
     FileSystem = LocalFileSystem.Instance;
     _tempDir   = FileSystem.CreateTempDirectory();
     Console.WriteLine("Temp path: " + _tempDir.Path);
     RootDir    = _tempDir.GetDirectory("root").MustExist();
     OutDir     = _tempDir.GetDirectory("outdir").MustExist();
     ConfigDir  = _tempDir.GetDirectory("config").MustExist();
     SysRepoDir = _tempDir.GetDirectory("sys").MustExist();
     SourceDir  = RootDir.GetDirectory("src");
 }
Exemplo n.º 16
0
 public override bool Loaded()
 {
     ServiceLocator.Clear();
     if (Host.config.ContainsKey("AA_CheckEnableAltitudeAngel"))
     {
         _enabled = Host.config.GetBoolean("AA_CheckEnableAltitudeAngel");
     }
     else
     {
         AskToEnableAltitudeAngel();
     }
     if (_enabled)
     {
         EnableAltitudeAngel();
     }
     return(true);
 }
Exemplo n.º 17
0
        protected openwrap_context()
        {
            // TODO: Review if we should use the Service registry?
            RemoteRepositories = new List <IPackageRepository>();
            ConfiguredRemotes  = new RemoteRepositories();
            ServiceLocator.Clear();
            var currentDirectory = System.Environment.CurrentDirectory;

            FileSystem  = given_file_system(currentDirectory);
            Environment = new InMemoryEnvironment(
                FileSystem.GetDirectory(currentDirectory),
                FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory));
            //Environment.DescriptorFile.MustExist();
            ServiceLocator.RegisterService <IFileSystem>(FileSystem);
            ServiceLocator.RegisterService <IEnvironment>(Environment);
            ServiceLocator.RegisterService <IPackageResolver>(new StrategyResolver());
            ServiceLocator.TryRegisterService <IPackageDeployer>(() => new DefaultPackageDeployer());
            ServiceLocator.TryRegisterService <IPackageExporter>(() => new DefaultPackageExporter(new IExportProvider[] {
                new DefaultAssemblyExporter(),
                new CecilCommandExporter()
            }));
            ServiceLocator.RegisterService <ICommandRepository>(Commands);

            ServiceLocator.TryRegisterService <IPackageManager>(PackageManagerFactory());

            ServiceLocator.RegisterService <IConfigurationManager>(new DefaultConfigurationManager(Environment.ConfigurationDirectory));


            Factory           = new MemoryRepositoryFactory();
            Factory.FromToken = token => RemoteRepositories.FirstOrDefault(repo => repo.Token == token);
            RemoteFactories   = new List <IRemoteRepositoryFactory> {
                Factory
            };

            ServiceLocator.TryRegisterService <IEnumerable <IRemoteRepositoryFactory> >(() => RemoteFactories);

            ConfigurationManager = ServiceLocator.GetService <IConfigurationManager>();
            ConfigurationManager.Save(ConfiguredRemotes);

            ServiceLocator.RegisterService <IRemoteManager>(new DefaultRemoteManager(ConfigurationManager, ServiceLocator.GetService <IEnumerable <IRemoteRepositoryFactory> >()));
        }
Exemplo n.º 18
0
 public void TearDown()
 {
     ServiceLocator.Clear();
 }
Exemplo n.º 19
0
 public void Setup()
 {
     ServiceLocator.Clear();
 }
Exemplo n.º 20
0
 internal static void Dispose()
 {
     ServiceLocator.Clear();
 }
Exemplo n.º 21
0
        public void CheckIfClearPreservesDefaultSetOfServices()
        {
            var locator = new ServiceLocator();
            var defaultNumberOfServices = locator.Count;

            Assert.AreNotEqual(0, defaultNumberOfServices);

            locator.Register(1u, new SimpleService());
            Assert.AreNotEqual(defaultNumberOfServices, locator.Count);

            locator.Clear();
            Assert.AreEqual(defaultNumberOfServices, locator.Count);
        }
Exemplo n.º 22
0
 public void TestCleanup()
 {
     ServiceLocator.Clear();
 }
Exemplo n.º 23
0
 public void TestInitialize()
 {
     ServiceLocator.Clear();
 }
Exemplo n.º 24
0
 public void TestInit()
 {
     ServiceLocator.Clear();
     MockRegistrationRepository.Clear();
 }
Exemplo n.º 25
0
 private void ConfigureServiceLocator()
 {
     ServiceLocator.Clear();
     ServiceLocator.Register(l => Host);
     ServiceLocator.Configure();
 }
Exemplo n.º 26
0
 public void ClearAndRegisterMissingHasServiceTest()
 {
     Assert.That(ServiceLocator.HasService <IObjectBuilder>(), Is.True);
     ServiceLocator.Clear();
     Assert.That(ServiceLocator.HasService <IObjectBuilder>(), Is.True);
 }
Exemplo n.º 27
0
 public void ClearAndRegisterMissingGetServiceTest()
 {
     Assert.That(ServiceLocator.GetService <IObjectBuilder>(), Is.Not.Null);
     ServiceLocator.Clear();
     Assert.That(ServiceLocator.GetService <IObjectBuilder>(), Is.Not.Null);
 }
 public void TestInit()
 {
     MockTrainingCourseRepository.Clear();
     ServiceLocator.Clear();
 }
Exemplo n.º 29
0
        public void RemovesAllRegisteredServices()
        {
            var locator = new ServiceLocator();
            var service = new SimpleService();
            var defaultNumberOfSerices = locator.Count;

            locator.Register(Guid.NewGuid(), service);
            locator.Register(new[] { typeof(ITestService), typeof(SimpleService) }, service);
            locator.Register(new[] { "Service1", "Service2" }, service);
            locator.Register(Guid.NewGuid(), ServiceMode.Clone, (sender, e) => { e.Service = new SimpleService(); });
            locator.Register(1u, service);
            locator.Register("Serice3", typeof(SimpleService), ServiceMode.Clone);

            Assert.AreNotEqual(0, locator.Count);
            Assert.AreEqual(8 + defaultNumberOfSerices, locator.Count);

            locator.Clear();
            Assert.AreEqual(defaultNumberOfSerices, locator.Count);

            var newService = locator.GetService(typeof(SimpleService));
            Assert.IsNotNull(newService);

            newService = locator.GetService(1u);
            Assert.IsNull(newService);

            newService = locator.GetService("Service1");
            Assert.IsNull(newService);
        }
 public void TestInit()
 {
     ServiceLocator.Clear();
     this.mockView = new TrainingBudgetMockView();
 }
Exemplo n.º 31
0
 private void Awake()
 {
     ServiceLocator.Clear();
     ServiceLocator.Register <Game>(this);
 }
Exemplo n.º 32
0
 public override bool Exit()
 {
     ServiceLocator.Clear();
     return(true);
 }