2018-08-28 17:32:59 -04:00
|
|
|
|
using IW4MAdmin.Application;
|
|
|
|
|
using SharedLibraryCore.Configuration;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
|
{
|
|
|
|
|
public class ManagerFixture : IDisposable
|
|
|
|
|
{
|
|
|
|
|
public ApplicationManager Manager { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ManagerFixture()
|
|
|
|
|
{
|
2019-06-24 12:01:34 -04:00
|
|
|
|
string logFile = @"X:\IW4MAdmin\Plugins\Tests\bin\Debug\netcoreapp2.2\test_mp.log";
|
2018-08-28 17:32:59 -04:00
|
|
|
|
|
2019-06-24 12:01:34 -04:00
|
|
|
|
File.WriteAllText(logFile, Environment.NewLine);
|
2018-10-12 22:28:22 -04:00
|
|
|
|
|
2020-01-13 21:06:57 -05:00
|
|
|
|
Manager = null;
|
2018-08-28 17:32:59 -04:00
|
|
|
|
|
|
|
|
|
var config = new ApplicationConfiguration
|
|
|
|
|
{
|
|
|
|
|
Servers = new List<ServerConfiguration>()
|
|
|
|
|
{
|
|
|
|
|
new ServerConfiguration()
|
|
|
|
|
{
|
|
|
|
|
AutoMessages = new List<string>(),
|
|
|
|
|
IPAddress = "127.0.0.1",
|
|
|
|
|
Password = "test",
|
2019-06-24 12:01:34 -04:00
|
|
|
|
Port = 28960,
|
2018-08-28 17:32:59 -04:00
|
|
|
|
Rules = new List<string>(),
|
2019-06-24 12:01:34 -04:00
|
|
|
|
RConParserVersion = "test",
|
|
|
|
|
EventParserVersion = "IW4x (v0.6.0)",
|
|
|
|
|
ManualLogPath = logFile
|
2018-08-28 17:32:59 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
AutoMessages = new List<string>(),
|
|
|
|
|
GlobalRules = new List<string>(),
|
|
|
|
|
Maps = new List<MapConfiguration>(),
|
2019-06-24 12:01:34 -04:00
|
|
|
|
RConPollRate = int.MaxValue
|
2018-08-28 17:32:59 -04:00
|
|
|
|
};
|
2019-06-24 12:01:34 -04:00
|
|
|
|
|
2019-04-05 22:15:17 -04:00
|
|
|
|
Manager.ConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("test");
|
2018-08-28 17:32:59 -04:00
|
|
|
|
Manager.ConfigHandler.Set(config);
|
2019-06-24 12:01:34 -04:00
|
|
|
|
Manager.AdditionalRConParsers.Add(new TestRconParser());
|
2018-08-28 17:32:59 -04:00
|
|
|
|
|
|
|
|
|
Manager.Init().Wait();
|
2018-10-12 22:28:22 -04:00
|
|
|
|
|
2018-08-28 17:32:59 -04:00
|
|
|
|
Task.Run(() => Manager.Start());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Manager.Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CollectionDefinition("ManagerCollection")]
|
|
|
|
|
public class ManagerCollection : ICollectionFixture<ManagerFixture>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|