2020-02-11 17:44:06 -05:00
|
|
|
|
using FakeItEasy;
|
|
|
|
|
using IW4MAdmin;
|
|
|
|
|
using IW4MAdmin.Application.EventParsers;
|
|
|
|
|
using NUnit.Framework;
|
2020-07-31 21:40:03 -04:00
|
|
|
|
using SharedLibraryCore.Configuration;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using System;
|
2020-11-12 20:46:17 -05:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
|
|
|
|
|
namespace ApplicationTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ServerTests
|
|
|
|
|
{
|
2020-11-12 20:46:17 -05:00
|
|
|
|
private IServiceProvider _serviceProvider;
|
|
|
|
|
|
2020-02-11 17:44:06 -05:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2020-11-12 20:46:17 -05:00
|
|
|
|
_serviceProvider = new ServiceCollection()
|
|
|
|
|
.BuildBase()
|
|
|
|
|
.BuildServiceProvider();
|
2020-02-11 17:44:06 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GameTimeFalseQuitTest()
|
|
|
|
|
{
|
2020-11-12 20:46:17 -05:00
|
|
|
|
var server = _serviceProvider.GetRequiredService<IW4MServer>();
|
2020-07-31 21:40:03 -04:00
|
|
|
|
var parser = new BaseEventParser(A.Fake<IParserRegexFactory>(), A.Fake<ILogger>(), A.Fake<ApplicationConfiguration>());
|
2020-02-11 17:44:06 -05:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void LogFileReplay()
|
|
|
|
|
{
|
2020-11-12 20:46:17 -05:00
|
|
|
|
var server = _serviceProvider.GetRequiredService<IW4MServer>();
|
2020-07-31 21:40:03 -04:00
|
|
|
|
var parser = new BaseEventParser(A.Fake<IParserRegexFactory>(), A.Fake<ILogger>(), A.Fake<ApplicationConfiguration>());
|
2020-02-11 17:44:06 -05:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|