public void Init()
 {
     IoCManager.Clear();
     IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService>());
     IoCManager.RegisterInstance(typeof(IImageDimension), Substitute.For <IImageDimension>());
     IoCManager.RegisterInstance(typeof(IMediaFileManager), Substitute.For <IMediaFileManager>());
 }
        private static void ParsedMain(CommandLineArgs args, bool contentStart)
        {
            IoCManager.InitThread();

            var mode = args.Headless ? DisplayMode.Headless : DisplayMode.Clyde;

            InitIoC(mode);

            var gc = (GameController)IoCManager.Resolve <IGameController>();

            gc.SetCommandLineArgs(args);

            // When the game is ran with the startup executable being content,
            // we have to disable the separate load context.
            // Otherwise the content assemblies will be loaded twice which causes *many* fun bugs.
            gc._disableAssemblyLoadContext = contentStart;
            if (!gc.Startup())
            {
                Logger.Fatal("Failed to start game controller!");
                return;
            }
            gc.MainLoop(mode);

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
示例#3
0
#pragma warning restore 649

        public static void Main()
        {
#if !X64
            throw new InvalidOperationException("The client cannot start outside x64.");
#endif

            IoCManager.InitThread();

            DisplayMode mode;
            if (Environment.GetCommandLineArgs().Contains("--headless"))
            {
                mode = DisplayMode.Headless;
            }
            else
            {
                mode = DisplayMode.Clyde;
            }

            InitIoC(mode);

            var gc = (GameController)IoCManager.Resolve <IGameController>();
            gc.Startup();
            gc.MainLoop(mode);

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
示例#4
0
        public void IoCTestCatchExceptionFromDisposingService()
        {
            IoCManager.Register <ITestDisposeExceptionCaught, TestDisposeExceptionCaught>();
            IoCManager.BuildGraph();

            IoCManager.Clear(); // should NOT throw an exception
        }
 public void Init()
 {
     IoCManager.Clear();
     IoCManager.RegisterInstance(typeof(IMediaFileManager), Substitute.For <IMediaFileManager>());
     IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService>());
     IoCManager.RegisterInstance(typeof(IDbChangedHandler), Substitute.For <IDbChangedHandler>());
 }
示例#6
0
        private static void ParsedMain(CommandLineArgs args, bool contentStart, ServerOptions options)
        {
            Thread.CurrentThread.Name = "Main Thread";
            IoCManager.InitThread();
            ServerIoC.RegisterIoC();
            IoCManager.BuildGraph();
            SetupLogging();
            InitReflectionManager();

            var server = IoCManager.Resolve <IBaseServerInternal>();

            server.ContentStart = contentStart;
            server.SetCommandLineArgs(args);

            Logger.Info("Server -> Starting");

            if (server.Start(options))
            {
                Logger.Fatal("Server -> Can not start server");
                //Not like you'd see this, haha. Perhaps later for logging.
                return;
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version !.ToString();

            Logger.Info("Server Version " + strVersion + " -> Ready");

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
#pragma warning restore 649

        public static void Main()
        {
            IoCManager.InitThread();

            DisplayMode mode;

            if (Environment.GetCommandLineArgs().Contains("--headless"))
            {
                mode = DisplayMode.Headless;
            }
            else
            {
                mode = DisplayMode.Clyde;
            }

            InitIoC(mode);

            var gc = (GameController)IoCManager.Resolve <IGameController>();

            gc.Startup();
            gc.MainLoop(mode);

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
示例#8
0
        private static void Main(string[] args)
        {
            //Register minidump dumper only if the app isn't being debugged. No use filling up hard drives with s***e
            RegisterIoC();
            LoadContentAssemblies();
            HandleCommandLineArgs();

            var server = IoCManager.Resolve <IBaseServer>();

            Logger.Log("Server -> Starting");

            if (server.Start())
            {
                Logger.Log("Server -> Can not start server", LogLevel.Fatal);
                //Not like you'd see this, haha. Perhaps later for logging.
                Environment.Exit(0);
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Logger.Log("Server Version " + strVersion + " -> Ready");

            // TODO: Move this to an interface.
            SignalHander.InstallSignals();

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
示例#9
0
        internal static void Main(string[] args)
        {
            IoCManager.InitThread();
            ServerIoC.RegisterIoC();
            IoCManager.BuildGraph();
            SetupLogging();
            InitReflectionManager();
            HandleCommandLineArgs(args);

            var server = IoCManager.Resolve <IBaseServer>();

            Logger.Info("Server -> Starting");

            if (server.Start())
            {
                Logger.Fatal("Server -> Can not start server");
                //Not like you'd see this, haha. Perhaps later for logging.
                //Environment.Exit(0);
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Logger.Info("Server Version " + strVersion + " -> Ready");

            IoCManager.Resolve <ISignalHandler>().MaybeStart();

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
示例#10
0
        private RoutesOverviewViewModel CreateSystemUnderTest()
        {
            IoCManager.Clear();
            var imageDimensions = Substitute.For <IImageDimension>();

            IoCManager.RegisterInstance(typeof(IImageDimension), imageDimensions);

            var route = Substitute.For <Route> ();

            var image = Substitute.For <Image> ();

            image.Data = new byte[] { 1, 2, 3, 4 };

            route.Description = "Test Description";
            route.Distance    = 10;
            route.Duration    = 4800;
            route.Title       = "Test Title";
            route.Image       = image;

            var dataAccess = Substitute.For <IDataAccess> ();

            dataAccess.GetItems <Route> ().Returns(new List <Route> {
                route
            });
            IoCManager.RegisterInstance(typeof(IDataAccess), dataAccess);
            IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService> ());

            return(new RoutesOverviewViewModel());
        }
        public AchievementConverterTest()
        {
            IoCManager.Clear();
            var sub = Substitute.For <IDataAccess>();

            IoCManager.RegisterInstance(typeof(IDataAccess), sub);
        }
示例#12
0
        public void BaseSetup()
        {
            // Clear state across tests.
            IoCManager.InitThread();
            IoCManager.Clear();

            RegisterIoC();

            var assemblies = new List <Assembly>(4);

            switch (Project)
            {
            case UnitTestProject.Client:
                assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Client"));
                break;

            case UnitTestProject.Server:
                assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Server"));
                break;

            default:
                throw new NotSupportedException($"Unknown testing project: {Project}");
            }

            assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));
            assemblies.Add(Assembly.GetExecutingAssembly());

            var configurationManager = IoCManager.Resolve <IConfigurationManagerInternal>();

            configurationManager.Initialize(Project == UnitTestProject.Server);

            foreach (var assembly in assemblies)
            {
                configurationManager.LoadCVarsFromAssembly(assembly);
            }

            var contentAssemblies = GetContentAssemblies();

            foreach (var assembly in contentAssemblies)
            {
                configurationManager.LoadCVarsFromAssembly(assembly);
            }

            IoCManager.Resolve <IReflectionManager>().LoadAssemblies(assemblies);

            var modLoader = IoCManager.Resolve <TestingModLoader>();

            modLoader.Assemblies = contentAssemblies;
            modLoader.TryLoadModulesFrom(ResourcePath.Root, "");

            // Required components for the engine to work
            var compFactory = IoCManager.Resolve <IComponentFactory>();

            if (!compFactory.AllRegisteredTypes.Contains(typeof(MetaDataComponent)))
            {
                compFactory.Register <MetaDataComponent>();
                compFactory.RegisterReference <MetaDataComponent, IMetaDataComponent>();
            }
        }
示例#13
0
        public void Setup()
        {
            var uiMgr = new Mock <IUserInterfaceManagerInternal>();

            IoCManager.InitThread();
            IoCManager.Clear();
            IoCManager.RegisterInstance <IUserInterfaceManagerInternal>(uiMgr.Object);
            IoCManager.RegisterInstance <IUserInterfaceManager>(uiMgr.Object);
            IoCManager.BuildGraph();
        }
示例#14
0
        public void ComponentChangedSerialized()
        {
            var container = new DependencyCollection();

            container.Register <ILogManager, LogManager>();
            container.Register <IConfigurationManager, ConfigurationManager>();
            container.Register <IConfigurationManagerInternal, ConfigurationManager>();
            container.Register <INetManager, NetManager>();
            container.Register <IReflectionManager, ServerReflectionManager>();
            container.Register <IRobustSerializer, RobustSerializer>();
            container.Register <IRobustMappedStringSerializer, RobustMappedStringSerializer>();
            container.Register <IAuthManager, AuthManager>();
            container.Register <IGameTiming, GameTiming>();
            container.BuildGraph();

            var cfg = container.Resolve <IConfigurationManagerInternal>();

            cfg.Initialize(true);
            cfg.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly);

            container.Resolve <IReflectionManager>().LoadAssemblies(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));

            IoCManager.InitThread(container);

            cfg.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly); // Robust.Shared

            container.Resolve <INetManager>().Initialize(true);

            var serializer = container.Resolve <IRobustSerializer>();

            serializer.Initialize();
            IoCManager.Resolve <IRobustMappedStringSerializer>().LockStrings();

            byte[] array;
            using (var stream = new MemoryStream())
            {
                var payload = new EntityState(
                    new EntityUid(512),
                    new []
                {
                    new ComponentChanged(false, NetIDs.MAP_GRID, nameof(MapGridComponent)),
                },
                    new []
                {
                    new MapGridComponentState(new GridId(0), true),
                });

                serializer.Serialize(stream, payload);
                array = stream.ToArray();
            }

            IoCManager.Clear();

            Assert.Pass($"Size in Bytes: {array.Length.ToString()}");
        }
示例#15
0
 public void Init()
 {
     IoCManager.Clear();
     navservice = Substitute.For <INavigationService> ();
     IoCManager.RegisterInstance(typeof(INavigationService), navservice);
     IoCManager.RegisterInstance(typeof(IImageDimension), Substitute.For <IImageDimension>());
     IoCManager.RegisterInstance(typeof(IDataAccess), Substitute.For <IDataAccess> ());
     IoCManager.RegisterInstance(typeof(IAudioPlayer), Substitute.For <IAudioPlayer> ());
     IoCManager.RegisterInstance(typeof(ILocationManager), Substitute.For <ILocationManager>());
     IoCManager.RegisterInstance(typeof(INearbyExhibitManager), Substitute.For <INearbyExhibitManager> ());
     IoCManager.RegisterInstance(typeof(INearbyRouteManager), Substitute.For <INearbyRouteManager>());
 }
示例#16
0
        private static void Main()
        {
            RegisterIoC();
            RegisterComponents();

            var controller = IoCManager.Resolve <IGameController>();

            controller.Run();

            Logger.Info("Goodbye.");
            IoCManager.Clear();
        }
示例#17
0
        public void BaseSetup()
        {
            TestFixtureAttribute a = Attribute.GetCustomAttribute(GetType(), typeof(TestFixtureAttribute)) as TestFixtureAttribute;

            if (NeedsResourcePack && Headless)
            {
                // Disable the test automatically.
                a.Explicit = true;
                return;
            }

            // Clear state across tests.
            IoCManager.Clear();
            RegisterIoC();

            var Assemblies = new List <Assembly>(4);

            switch (Project)
            {
            case UnitTestProject.Client:
                Assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("SS14.Client"));
                break;

            case UnitTestProject.Server:
                Assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("SS14.Server"));
                break;

            default:
                throw new NotSupportedException($"Unknown testing project: {Project}");
            }

            Assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("SS14.Shared"));
            Assemblies.Add(Assembly.GetExecutingAssembly());

            IoCManager.Resolve <IReflectionManager>().LoadAssemblies(Assemblies);

            if (NeedsClientConfig)
            {
                //ConfigurationManager setup
                GetConfigurationManager = IoCManager.Resolve <IConfigurationManager>();
                GetConfigurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("./client_config.toml"));
            }

            /*
             * if (NeedsResourcePack)
             * {
             *  GetResourceCache = IoCManager.Resolve<IResourceCache>();
             *  InitializeResources();
             * }
             */
        }
 public void Init()
 {
     IoCManager.Clear();
     IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService>());
     IoCManager.RegisterInstance(typeof(IImageDimension), Substitute.For <IImageDimension>());
     IoCManager.RegisterInstance(typeof(IDataAccess), Substitute.For <IDataAccess>());
     IoCManager.RegisterInstance(typeof(IAudioPlayer), Substitute.For <IAudioPlayer>());
     IoCManager.RegisterInstance(typeof(ILocationManager), Substitute.For <ILocationManager>());
     IoCManager.RegisterInstance(typeof(INearbyExhibitManager), Substitute.For <INearbyExhibitManager>());
     IoCManager.RegisterInstance(typeof(INearbyRouteManager), Substitute.For <INearbyRouteManager>());
     IoCManager.RegisterInstance(typeof(IDbChangedHandler), Substitute.For <IDbChangedHandler>());
     IoCManager.RegisterInstance(typeof(IMediaFileManager), Substitute.For <IMediaFileManager>());
     IoCManager.RegisterInstance(typeof(INewDataCenter), Substitute.For <INewDataCenter>());
 }
 public void Shutdown(string reason = null)
 {
     if (reason != null)
     {
         Logger.Info($"Shutting down! Reason: {reason}");
     }
     else
     {
         Logger.Info("Shutting down!");
     }
     Logger.Debug("Goodbye");
     IoCManager.Clear();
     _sceneTreeHolder.SceneTree.Quit();
 }
示例#20
0
        public SS14UnitTest()
        {
            TestFixtureAttribute a = Attribute.GetCustomAttribute(GetType(), typeof(TestFixtureAttribute)) as TestFixtureAttribute;

            if (NeedsResourcePack && Headless)
            {
                // Disable the test automatically.
                a.Explicit = true;
                return;
            }

            // Clear state across tests.
            IoCManager.Clear();
            RegisterIoC();

            var    Assemblies  = new List <Assembly>(4);
            string AssemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            switch (Project)
            {
            case UnitTestProject.Client:
                Assemblies.Add(Assembly.LoadFrom(Path.Combine(AssemblyDir, "SS14.Client.exe")));
                break;

            case UnitTestProject.Server:
                Assemblies.Add(Assembly.LoadFrom(Path.Combine(AssemblyDir, "SS14.Server.exe")));
                break;

            default:
                throw new NotSupportedException($"Unknown testing project: {Project}");
            }

            Assemblies.Add(Assembly.LoadFrom(Path.Combine(AssemblyDir, "SS14.Shared.dll")));
            Assemblies.Add(Assembly.GetExecutingAssembly());

            IoCManager.Resolve <IReflectionManager>().LoadAssemblies(Assemblies);

            if (NeedsClientConfig)
            {
                //ConfigurationManager setup
                GetConfigurationManager = IoCManager.Resolve <IConfigurationManager>();
                GetConfigurationManager.LoadFromFile(PathHelpers.AssemblyRelativeFile("./client_config.toml", Assembly.GetExecutingAssembly()));
            }

            if (NeedsResourcePack)
            {
                GetResourceManager = IoCManager.Resolve <IResourceManager>();
                InitializeResources();
            }
        }
        private AudioToolbarViewModel CreateSystemUnderTest(bool automaticallyStartAudio = false)
        {
            IoCManager.Clear();
            var audioPlayer = Substitute.For <IAudioPlayer> ();

            IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService>());
            IoCManager.RegisterInstance(typeof(IAudioPlayer), audioPlayer);
            audioPlayer.MaximumProgress.Returns(42);

            var audio     = Substitute.For <Audio> ();
            var viewmodel = new AudioToolbarViewModel(automaticallyStartAudio, "Title");

            viewmodel.SetNewAudioFile(audio);

            return(viewmodel);
        }
示例#22
0
 public void Shutdown(string reason = null)
 {
     if (reason != null)
     {
         Logger.Info($"Shutting down! Reason: {reason}");
     }
     else
     {
         Logger.Info("Shutting down!");
     }
     Logger.Debug("Goodbye");
     IoCManager.Clear();
     ShuttingDownHard = true;
     // Hahaha Godot is crashing absurdly and I can't be bothered to fix it.
     // Hey now it shuts down easily.
     Environment.Exit(0);
 }
        private static void ParsedMain(CommandLineArgs args)
        {
            IoCManager.InitThread();

            var mode = args.Headless ? DisplayMode.Headless : DisplayMode.Clyde;

            InitIoC(mode);

            var gc = (GameController)IoCManager.Resolve <IGameController>();

            gc.SetCommandLineArgs(args);
            gc.Startup();
            gc.MainLoop(mode);

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
示例#24
0
        private AudioToolbarViewModel CreateSystemUnderTest()
        {
            IoCManager.Clear();
            var audioPlayer = Substitute.For <IAudioPlayer>();

            IoCManager.RegisterInstance(typeof(INavigationService), Substitute.For <INavigationService>());
            IoCManager.RegisterInstance(typeof(IAudioPlayer), audioPlayer);
            IoCManager.RegisterInstance(typeof(IMediaFileManager), new DummyMediaFileManager());
            audioPlayer.MaximumProgress.Returns(42);

            var audio     = Substitute.For <Audio>();
            var viewmodel = new AudioToolbarViewModel("Title", true);

            viewmodel.SetNewAudioFile(audio);

            return(viewmodel);
        }
示例#25
0
        public static void Run(Action postInit, InitialWindowParameters windowParameters = null)
        {
            IoCManager.InitThread();

            ClientIoC.RegisterIoC(GameController.DisplayMode.Clyde);
            IoCManager.Register <IGameController, LiteGameController>(true);
            IoCManager.Register <IGameControllerInternal, LiteGameController>(true);
            IoCManager.Register <LiteGameController, LiteGameController>(true);
            IoCManager.BuildGraph();

            var gc = IoCManager.Resolve <LiteGameController>();

            gc.Startup(windowParameters);

            IoCManager.Resolve <ITaskManager>().RunOnMainThread(postInit);
            gc.MainLoop(GameController.DisplayMode.Clyde);

            IoCManager.Clear();
        }
        public void Run(DisplayMode mode, GameControllerOptions options, Func <ILogHandler>?logHandlerFactory = null)
        {
            if (!StartupSystemSplash(options, logHandlerFactory))
            {
                Logger.Fatal("Failed to start game controller!");
                return;
            }

            if (_clyde.SeparateWindowThread)
            {
                var stackSize = _configurationManager.GetCVar(CVars.SysGameThreadStackSize);
                var priority  = (ThreadPriority)_configurationManager.GetCVar(CVars.SysGameThreadPriority);

                _gameThread = new Thread(() => GameThreadMain(mode), stackSize)
                {
                    IsBackground = false,
                    Priority     = priority,
                    Name         = "Game thread",
                };

                _gameThread.Start();

                // Will block until game exit
                _clyde.EnterWindowLoop();

                if (_gameThread.IsAlive)
                {
                    Logger.Debug("Window loop exited; waiting for game thread to exit");
                    _gameThread.Join();
                }
            }
            else
            {
                ContinueStartupAndLoop(mode);
            }

            Cleanup();

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
示例#27
0
        private static void ParsedMain(CommandLineArgs args, bool contentStart)
        {
            Thread.CurrentThread.Name = "Main Thread";
            IoCManager.InitThread();
            ServerIoC.RegisterIoC();
            IoCManager.BuildGraph();
            SetupLogging();
            InitReflectionManager();

            var server = IoCManager.Resolve <IBaseServerInternal>();

            // When the game is ran with the startup executable being content,
            // we have to disable the separate load context.
            // Otherwise the content assemblies will be loaded twice which causes *many* fun bugs.
            server.DisableLoadContext = contentStart;
            server.SetCommandLineArgs(args);

            Logger.Info("Server -> Starting");

            if (server.Start())
            {
                Logger.Fatal("Server -> Can not start server");
                //Not like you'd see this, haha. Perhaps later for logging.
                return;
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version !.ToString();

            Logger.Info("Server Version " + strVersion + " -> Ready");

            IoCManager.Resolve <ISignalHandler>().MaybeStart();

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
        private static void ParsedMain(CommandLineArgs args, bool contentStart)
        {
            IoCManager.InitThread();

            var mode = args.Headless ? DisplayMode.Headless : DisplayMode.Clyde;

            InitIoC(mode);

            var gc = (GameController)IoCManager.Resolve <IGameController>();

            gc.SetCommandLineArgs(args);
            gc._disableAssemblyLoadContext = contentStart;
            if (!gc.Startup())
            {
                Logger.Fatal("Failed to start game controller!");
                return;
            }
            gc.MainLoop(mode);

            Logger.Debug("Goodbye");
            IoCManager.Clear();
        }
        private void InitHttpContextThread()
        {
            if (SynchronizationContext.Current == _syncCtx)
            {
                // maybe assert instead?
                return;
            }

            IoCManager.Clear();
            ILogManager logMgr = null;

            WaitSync(() =>
            {
                logMgr = IoCManager.Resolve <ILogManager>();
            }, ApplicationStopping);
            IoCManager.InitThread();
            if (logMgr != null)
            {
                IoCManager.RegisterInstance <ILogManager>(logMgr);
            }

            IoCManager.BuildGraph();
        }
示例#30
0
        public void Shutdown(string reason = null)
        {
            if (reason != null)
            {
                Logger.Info($"Shutting down! Reason: {reason}");
            }
            else
            {
                Logger.Info("Shutting down!");
            }

            if (Mode != DisplayMode.Godot)
            {
                _mainLoop.Running = false;
            }
            presence.Free();
            Logger.Debug("Goodbye");
            IoCManager.Clear();
            ShuttingDownHard = true;
            // Hahaha Godot is crashing absurdly and I can't be bothered to fix it.
            // Hey now it shuts down easily.
            Environment.Exit(0);
        }