More progress on IoC. Controllers are implemented
This commit is contained in:
		@@ -1,9 +1,14 @@
 | 
			
		||||
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 System.Threading.Tasks;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using Autofac;
 | 
			
		||||
 | 
			
		||||
namespace Aurora.test.ControllerTests
 | 
			
		||||
{
 | 
			
		||||
@@ -11,10 +16,35 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
    {
 | 
			
		||||
        private RemotePartyService.RemotePartyServiceClient _remotePartyService;
 | 
			
		||||
        private Channel _channel;
 | 
			
		||||
        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}/Resources", Directory.GetCurrentDirectory())
 | 
			
		||||
            }).SingleInstance();
 | 
			
		||||
            builder.RegisterType<LibraryService>().As<ILibraryService>().SingleInstance();
 | 
			
		||||
            _container = builder.Build();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [OneTimeTearDown]
 | 
			
		||||
        public void TearDownOneTime()
 | 
			
		||||
        {
 | 
			
		||||
            _container.Dispose();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [SetUp]
 | 
			
		||||
        public void Setup()
 | 
			
		||||
        {
 | 
			
		||||
            ServerService.Instance.Start("testParty", "asdf");
 | 
			
		||||
            _serverService = _container.Resolve<IServerService>();
 | 
			
		||||
            _serverService.Start("testParty", "asdf");
 | 
			
		||||
            _channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
 | 
			
		||||
            _remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
 | 
			
		||||
        }
 | 
			
		||||
@@ -22,8 +52,22 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
        [TearDown]
 | 
			
		||||
        public async Task TearDown()
 | 
			
		||||
        {
 | 
			
		||||
            await ServerService.Instance.Stop();
 | 
			
		||||
            await _serverService.Stop();
 | 
			
		||||
            await _channel.ShutdownAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Test]
 | 
			
		||||
        public void TestNotEmpty()
 | 
			
		||||
        {
 | 
			
		||||
            ListMediaResponse resp = _remotePartyService.ListMedia(new ListMediaRequest()
 | 
			
		||||
            {
 | 
			
		||||
                Parent = "testParty",
 | 
			
		||||
                PageSize = 5
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            Assert.NotNull(resp.Media);
 | 
			
		||||
            Assert.NotZero(resp.Media.Count);
 | 
			
		||||
            Assert.AreEqual(resp.Media.Count, 5);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,14 @@
 | 
			
		||||
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 System.Threading.Tasks;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using Autofac;
 | 
			
		||||
 | 
			
		||||
namespace Aurora.test.ControllerTests
 | 
			
		||||
{
 | 
			
		||||
@@ -11,10 +16,36 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
    {
 | 
			
		||||
        private RemotePartyService.RemotePartyServiceClient _remotePartyService;
 | 
			
		||||
        private Channel _channel;
 | 
			
		||||
 | 
			
		||||
        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();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [SetUp]
 | 
			
		||||
        public void Setup()
 | 
			
		||||
        {
 | 
			
		||||
            ServerService.Instance.Start("testParty", "asdf");
 | 
			
		||||
            _serverService = _container.Resolve<IServerService>();
 | 
			
		||||
            _serverService.Start("testParty", "asdf");
 | 
			
		||||
            _channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
 | 
			
		||||
            _remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
 | 
			
		||||
        }
 | 
			
		||||
@@ -22,7 +53,7 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
        [TearDown]
 | 
			
		||||
        public async Task TearDown()
 | 
			
		||||
        {
 | 
			
		||||
            await ServerService.Instance.Stop();
 | 
			
		||||
            await _serverService.Stop();
 | 
			
		||||
            await _channel.ShutdownAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,13 @@
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
@@ -10,10 +15,35 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
    {
 | 
			
		||||
        private RemotePartyService.RemotePartyServiceClient _remotePartyService;
 | 
			
		||||
        private Channel _channel;
 | 
			
		||||
        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();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [SetUp]
 | 
			
		||||
        public void Setup()
 | 
			
		||||
        {
 | 
			
		||||
            ServerService.Instance.Start("testParty", "asdf");
 | 
			
		||||
            _serverService = _container.Resolve<IServerService>();
 | 
			
		||||
            _serverService.Start("testParty", "asdf");
 | 
			
		||||
            _channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
 | 
			
		||||
            _remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
 | 
			
		||||
        }
 | 
			
		||||
@@ -21,7 +51,7 @@ namespace Aurora.test.ControllerTests
 | 
			
		||||
        [TearDown]
 | 
			
		||||
        public async Task TearDown()
 | 
			
		||||
        {
 | 
			
		||||
            await ServerService.Instance.Stop();
 | 
			
		||||
            await _serverService.Stop();
 | 
			
		||||
            await _channel.ShutdownAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user