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