2020-01-21 03:53:33 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-02 15:26:47 +00:00
|
|
|
using System.IO;
|
2020-01-20 23:38:05 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using Aurora.Proto.PartyV2;
|
|
|
|
using Aurora.Services.Server;
|
2020-02-02 15:26:47 +00:00
|
|
|
using Aurora.Services.Library;
|
|
|
|
using Aurora.Services.Settings;
|
|
|
|
using Aurora.test.Models.Mock;
|
2020-01-20 23:38:05 +00:00
|
|
|
using Grpc.Core;
|
2020-02-02 15:26:47 +00:00
|
|
|
using Autofac;
|
2020-01-20 23:38:05 +00:00
|
|
|
|
2020-01-21 03:53:33 +00:00
|
|
|
namespace Aurora.test.ControllerTests
|
2020-01-20 23:38:05 +00:00
|
|
|
{
|
2020-01-21 03:53:33 +00:00
|
|
|
public class PartyControllerTests
|
2020-01-20 23:38:05 +00:00
|
|
|
{
|
|
|
|
private RemotePartyService.RemotePartyServiceClient _remotePartyService;
|
|
|
|
private Channel _channel;
|
2020-02-02 15:26:47 +00:00
|
|
|
private IContainer _container;
|
|
|
|
private IServerService _serverService;
|
|
|
|
|
|
|
|
[OneTimeSetUp]
|
|
|
|
public void SetupOneTime()
|
|
|
|
{
|
|
|
|
ContainerBuilder builder = new ContainerBuilder();
|
|
|
|
builder.RegisterType<ServerService>().As<IServerService>().SingleInstance();
|
|
|
|
builder.RegisterInstance<ISettingsService>(new SettingsServiceMock()
|
|
|
|
{
|
|
|
|
Username = "Test User 1",
|
|
|
|
DefaultPort = 4005,
|
|
|
|
LibraryLocation = string.Format("{0}/Resource", Directory.GetCurrentDirectory())
|
|
|
|
}).SingleInstance();
|
|
|
|
builder.RegisterType<LibraryService>().As<ILibraryService>().SingleInstance();
|
|
|
|
_container = builder.Build();
|
|
|
|
}
|
|
|
|
|
|
|
|
[OneTimeTearDown]
|
|
|
|
public void TearDownOneTime()
|
|
|
|
{
|
|
|
|
_container.Dispose();
|
|
|
|
}
|
|
|
|
|
2020-01-20 23:38:05 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2020-02-02 15:26:47 +00:00
|
|
|
_serverService = _container.Resolve<IServerService>();
|
|
|
|
_serverService.Start("testParty", "asdf");
|
2020-01-20 23:38:05 +00:00
|
|
|
_channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
|
|
|
|
_remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
|
|
|
|
}
|
|
|
|
|
2020-01-21 03:53:33 +00:00
|
|
|
[TearDown]
|
|
|
|
public async Task TearDown()
|
|
|
|
{
|
2020-02-02 15:26:47 +00:00
|
|
|
await _serverService.Stop();
|
2020-01-21 03:53:33 +00:00
|
|
|
await _channel.ShutdownAsync();
|
|
|
|
}
|
|
|
|
|
2020-01-20 23:38:05 +00:00
|
|
|
[Test]
|
2020-01-21 03:53:33 +00:00
|
|
|
public void DefaultTest()
|
2020-01-20 23:38:05 +00:00
|
|
|
{
|
2020-01-21 03:53:33 +00:00
|
|
|
Party party = _remotePartyService.GetParty(new Proto.General.Empty());
|
|
|
|
|
|
|
|
Assert.NotNull(party);
|
|
|
|
Assert.AreEqual(party.Name, "party/party1");
|
2020-01-20 23:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|