Ejemplo n.º 1
0
        /// <summary>
        /// This example shows how to use logging with a very simple console logger that does not need any extra references.
        /// </summary>
        private static void LogWithSimpleProvider()
        {
            LogDispatcher.LoggerFactory = new SimpleConsoleLoggerFactory();

            var testee = new MyTestComponent();

            testee.DoSomeLogging();
            LogDispatcher.LoggerFactory = null;
        }
Ejemplo n.º 2
0
        public void OnStartServerTest()
        {
            var             gameObject = new GameObject();
            NetworkIdentity identity   = gameObject.AddComponent <NetworkIdentity>();

            // lets add a component to check OnStartserver

            MyTestComponent component1 = gameObject.AddComponent <MyTestComponent>();
            MyTestComponent component2 = gameObject.AddComponent <MyTestComponent>();

            identity.OnStartServer();

            Assert.That(component1.onStartServerInvoked);
            Assert.That(component2.onStartServerInvoked);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This example shows how to enable logging to the console by using the implementations in
        /// Microsoft.Extensions.Logging.dll and Microsoft.Extensions.Logging.Console.dll. Both packages need to be referenced.
        /// </summary>
        private static void LogWithStandardProvider()
        {
            using var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddConsole();
            });

            // Statically register our factory. Note that this must be done before instantiation of any class that wants to use logging.
            LogDispatcher.LoggerFactory = loggerFactory;

            var testee = new MyTestComponent();

            testee.DoSomeLogging();
            LogDispatcher.LoggerFactory = null;
        }