コード例 #1
0
        public void LogFileReplay()
        {
            var mgr = A.Fake <IManager>();

            A.CallTo(() => mgr.GetLogger(A <long> .Ignored)).Returns(logger);

            var server = new IW4MServer(mgr,
                                        new SharedLibraryCore.Configuration.ServerConfiguration()
            {
                IPAddress = "127.0.0.1", Port = 28960
            },
                                        A.Fake <ITranslationLookup>(), A.Fake <IRConConnectionFactory>(), A.Fake <IGameLogReaderFactory>(), A.Fake <IMetaService>());

            var parser = new BaseEventParser(A.Fake <IParserRegexFactory>(), A.Fake <ILogger>(), A.Fake <ApplicationConfiguration>());

            parser.Configuration.GuidNumberStyle = System.Globalization.NumberStyles.Integer;

            var  log         = System.IO.File.ReadAllLines("Files\\T6Game.log");
            long lastEventId = 0;

            foreach (string line in log)
            {
                var e = parser.GenerateGameEvent(line);
                server.Logger.WriteInfo($"{e.GameTime}");
                if (e.Origin != null)
                {
                    e.Origin.CurrentServer = server;
                }

                server.ExecuteEvent(e).Wait();
                lastEventId = e.Id;
            }

            Assert.GreaterOrEqual(lastEventId, log.Length);
        }
コード例 #2
0
        public void GameTimeFalseQuitTest()
        {
            var mgr    = A.Fake <IManager>();
            var server = new IW4MServer(mgr,
                                        new SharedLibraryCore.Configuration.ServerConfiguration()
            {
                IPAddress = "127.0.0.1", Port = 28960
            },
                                        A.Fake <ITranslationLookup>(), A.Fake <IRConConnectionFactory>(), A.Fake <IGameLogReaderFactory>(), A.Fake <IMetaService>());

            var parser = new BaseEventParser(A.Fake <IParserRegexFactory>(), A.Fake <ILogger>(), A.Fake <ApplicationConfiguration>());

            parser.Configuration.GuidNumberStyle = System.Globalization.NumberStyles.Integer;

            var log = System.IO.File.ReadAllLines("Files\\T6MapRotation.log");

            foreach (string line in log)
            {
                var e = parser.GenerateGameEvent(line);
                if (e.Origin != null)
                {
                    e.Origin.CurrentServer = server;
                }

                server.ExecuteEvent(e).Wait();
            }
        }
コード例 #3
0
ファイル: ServerTests.cs プロジェクト: xerxes-at/IW4M-Admin
        public void GameTimeFalseQuitTest()
        {
            var server = _serviceProvider.GetRequiredService <IW4MServer>();
            var parser = new BaseEventParser(A.Fake <IParserRegexFactory>(), A.Fake <ILogger>(), A.Fake <ApplicationConfiguration>());

            parser.Configuration.GuidNumberStyle = System.Globalization.NumberStyles.Integer;

            var log = System.IO.File.ReadAllLines("Files\\T6MapRotation.log");

            foreach (string line in log)
            {
                var e = parser.GenerateGameEvent(line);
                if (e.Origin != null)
                {
                    e.Origin.CurrentServer = server;
                }

                server.ExecuteEvent(e).Wait();
            }
        }
コード例 #4
0
ファイル: ServerTests.cs プロジェクト: xerxes-at/IW4M-Admin
        public void LogFileReplay()
        {
            var server = _serviceProvider.GetRequiredService <IW4MServer>();
            var parser = new BaseEventParser(A.Fake <IParserRegexFactory>(), A.Fake <ILogger>(), A.Fake <ApplicationConfiguration>());

            parser.Configuration.GuidNumberStyle = System.Globalization.NumberStyles.Integer;

            var  log         = System.IO.File.ReadAllLines("Files\\T6Game.log");
            long lastEventId = 0;

            foreach (string line in log)
            {
                var e = parser.GenerateGameEvent(line);
                if (e.Origin != null)
                {
                    e.Origin.CurrentServer = server;
                }

                server.ExecuteEvent(e).Wait();
                lastEventId = e.Id;
            }

            Assert.GreaterOrEqual(lastEventId, log.Length);
        }
コード例 #5
0
ファイル: StatsTests.cs プロジェクト: xerxes-at/IW4M-Admin
        public void TestKDR()
        {
            var mgr    = A.Fake <IManager>();
            var config = A.Fake <IConfigurationHandler <StatsConfiguration> >();
            var plugin = serviceProvider.GetRequiredService <IW4MAdmin.Plugins.Stats.Plugin>();

            A.CallTo(() => config.Configuration())
            .Returns(new StatsConfiguration()
            {
                EnableAntiCheat = true
            });

            A.CallTo(() => handlerFactory.GetConfigurationHandler <StatsConfiguration>(A <string> .Ignored))
            .Returns(config);

            var server = serviceProvider.GetRequiredService <IW4MServer>();

            var parser = new BaseEventParser(A.Fake <IParserRegexFactory>(), A.Fake <ILogger>(), A.Fake <ApplicationConfiguration>());

            parser.Configuration.GuidNumberStyle = System.Globalization.NumberStyles.Integer;

            var log = System.IO.File.ReadAllLines("Files\\T6GameStats.log");

            plugin.OnLoadAsync(mgr).Wait();
            plugin.OnEventAsync(new SharedLibraryCore.GameEvent()
            {
                Type = SharedLibraryCore.GameEvent.EventType.Start, Owner = server
            }, server).Wait();

            var clientList = new Dictionary <long, EFClient>();

            foreach (string line in log)
            {
                var e = parser.GenerateGameEvent(line);
                if (e.Origin != null)
                {
                    //if (!clientList.ContainsKey(e.Origin.NetworkId))
                    //{
                    //    clientList.Add(e.Origin.NetworkId, e.Origin);
                    //}

                    //else
                    //{
                    //    e.Origin = clientList[e.Origin.NetworkId];
                    //}

                    e.Origin = server.GetClientsAsList().FirstOrDefault(_client => _client.NetworkId == e.Origin.NetworkId) ?? e.Origin;
                    e.Origin.CurrentServer = server;
                }

                if (e.Target != null)
                {
                    //if (!clientList.ContainsKey(e.Target.NetworkId))
                    //{
                    //    clientList.Add(e.Target.NetworkId, e.Target);
                    //}

                    //else
                    //{
                    //    e.Target = clientList[e.Target.NetworkId];
                    //}

                    e.Target = server.GetClientsAsList().FirstOrDefault(_client => _client.NetworkId == e.Target.NetworkId) ?? e.Target;
                    e.Target.CurrentServer = server;
                }

                server.ExecuteEvent(e).Wait();
                plugin.OnEventAsync(e, server).Wait();
            }

            var client = server.GetClientsAsList().First(_client => _client?.NetworkId == 2028755667);
            var stats  = client.GetAdditionalProperty <EFClientStatistics>("ClientStats");
        }