Refactored naming and directory layout of project.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\GameServiceWarden.Host\GameServiceWarden.Host.csproj" />
|
||||
<ProjectReference Include="..\..\src\GameServiceWarden.Core\GameServiceWarden.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\GameServiceWarden.ModuleAPI\GameServiceWarden.ModuleAPI.csproj" />
|
||||
</ItemGroup>
|
||||
|
@@ -1,13 +1,13 @@
|
||||
using GameServiceWarden.ModuleAPI;
|
||||
|
||||
namespace GameServiceWarden.Host.Tests.Modules
|
||||
namespace GameServiceWarden.Core.Tests.Modules.Games
|
||||
{
|
||||
public class FakeConfigurable : IConfigurable
|
||||
public class FakeGameConfigurable : IGameConfigurable
|
||||
{
|
||||
private string value;
|
||||
public string OptionName { get; private set; }
|
||||
|
||||
public FakeConfigurable(string optionName)
|
||||
public FakeGameConfigurable(string optionName)
|
||||
{
|
||||
this.OptionName = optionName;
|
||||
}
|
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using GameServiceWarden.ModuleAPI;
|
||||
|
||||
namespace GameServiceWarden.Host.Tests.Modules
|
||||
namespace GameServiceWarden.Core.Tests.Modules.Games
|
||||
{
|
||||
public class FakeService : IGameService
|
||||
public class FakeGameService : IGameService
|
||||
{
|
||||
public IReadOnlyCollection<IConfigurable> Configurables { get; set; }
|
||||
public IReadOnlyCollection<IGameConfigurable> Configurables { get; set; }
|
||||
|
||||
public event EventHandler<ServiceState> StateChangeEvent;
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
|
||||
private TextWriter consoleStream;
|
||||
|
||||
public FakeService(params IConfigurable[] configurables)
|
||||
public FakeGameService(params IGameConfigurable[] configurables)
|
||||
{
|
||||
HashSet<IConfigurable> modifiable = new HashSet<IConfigurable>();
|
||||
foreach (IConfigurable configurable in configurables)
|
||||
HashSet<IGameConfigurable> modifiable = new HashSet<IGameConfigurable>();
|
||||
foreach (IGameConfigurable configurable in configurables)
|
||||
{
|
||||
modifiable.Add(configurable);
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using GameServiceWarden.ModuleAPI;
|
||||
|
||||
namespace GameServiceWarden.Host.Tests.Modules
|
||||
namespace GameServiceWarden.Core.Tests.Modules.Games
|
||||
{
|
||||
public class FakeGameServiceModule : IGameServiceModule
|
||||
{
|
||||
@@ -9,8 +9,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
|
||||
public string Description => "A fake module for testing.";
|
||||
|
||||
private IConfigurable[] configurables;
|
||||
public FakeGameServiceModule(params IConfigurable[] configurables)
|
||||
private IGameConfigurable[] configurables;
|
||||
public FakeGameServiceModule(params IGameConfigurable[] configurables)
|
||||
{
|
||||
this.configurables = configurables;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
|
||||
public IGameService CreateGameService()
|
||||
{
|
||||
return new FakeService(configurables);
|
||||
return new FakeGameService(configurables);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,24 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using GameServiceWarden.Host.Modules;
|
||||
using GameServiceWarden.Core.Games;
|
||||
using GameServiceWarden.ModuleAPI;
|
||||
using Xunit;
|
||||
|
||||
namespace GameServiceWarden.Host.Tests.Modules
|
||||
namespace GameServiceWarden.Core.Tests.Modules.Games
|
||||
{
|
||||
// Testing convention from: https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices
|
||||
// Fakes are generic test objects,
|
||||
// mocks are the objects being asserted upon,
|
||||
// stubs are objects used as part of the test.
|
||||
public class ServiceInfoTest
|
||||
public class GameServiceInfoTest
|
||||
{
|
||||
//MethodTested_ScenarioTested_ExpectedBehavior
|
||||
[Fact]
|
||||
public void Start_FromStopped_StateIsRunning()
|
||||
{
|
||||
//Arrange, Act, Assert
|
||||
IGameService stubGameService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubGameService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubGameService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubGameService, "FakeModule", "FakeAssembly");
|
||||
serviceInfo.Start();
|
||||
Assert.Equal(ServiceState.Running, serviceInfo.GetServiceState());
|
||||
serviceInfo.Dispose();
|
||||
@@ -27,8 +27,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
[Fact]
|
||||
public void Stop_FromStart_Stopped()
|
||||
{
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
serviceInfo.Start();
|
||||
serviceInfo.Stop();
|
||||
Assert.Equal(ServiceState.Stopped, serviceInfo.GetServiceState());
|
||||
@@ -39,12 +39,12 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void GetConfigurableOptions_ServiceStopped_ReturnsConfigurables()
|
||||
{
|
||||
//Given
|
||||
FakeService stubService = new FakeService();
|
||||
FakeConfigurable stubConfigurable = new FakeConfigurable("Option");
|
||||
HashSet<IConfigurable> configurables = new HashSet<IConfigurable>();
|
||||
FakeGameService stubService = new FakeGameService();
|
||||
FakeGameConfigurable stubConfigurable = new FakeGameConfigurable("Option");
|
||||
HashSet<IGameConfigurable> configurables = new HashSet<IGameConfigurable>();
|
||||
configurables.Add(stubConfigurable);
|
||||
stubService.Configurables = configurables;
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//Then
|
||||
Assert.Contains<string>(stubConfigurable.OptionName, serviceInfo.GetConfigurableOptions());
|
||||
serviceInfo.Dispose();
|
||||
@@ -54,12 +54,12 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void SetAndGetConfigurationValue_ServiceStopped_AppropriateValueReturned()
|
||||
{
|
||||
//Given
|
||||
FakeService stubService = new FakeService();
|
||||
FakeConfigurable stubConfigurable = new FakeConfigurable("Option");
|
||||
HashSet<IConfigurable> configurables = new HashSet<IConfigurable>();
|
||||
FakeGameService stubService = new FakeGameService();
|
||||
FakeGameConfigurable stubConfigurable = new FakeGameConfigurable("Option");
|
||||
HashSet<IGameConfigurable> configurables = new HashSet<IGameConfigurable>();
|
||||
configurables.Add(stubConfigurable);
|
||||
stubService.Configurables = configurables;
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//When
|
||||
serviceInfo.SetConfigurableValue(stubConfigurable.OptionName, "success");
|
||||
//Then
|
||||
@@ -70,8 +70,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void GetServiceState_ServiceNotStarted_ReturnsStoppedState()
|
||||
{
|
||||
//Given
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//Then
|
||||
Assert.Equal(ServiceState.Stopped, serviceInfo.GetServiceState());
|
||||
serviceInfo.Dispose();
|
||||
@@ -81,8 +81,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void GetServiceState_ServiceStarted_ReturnsRunningState()
|
||||
{
|
||||
//Given
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//When
|
||||
serviceInfo.Start();
|
||||
//Then
|
||||
@@ -95,8 +95,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
{
|
||||
//Given
|
||||
const string MODULE_NAME = "FakeModule";
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, MODULE_NAME, "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, MODULE_NAME, "FakeAssembly");
|
||||
//Then
|
||||
Assert.Equal(MODULE_NAME, serviceInfo.GetModuleName());
|
||||
serviceInfo.Dispose();
|
||||
@@ -107,8 +107,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
{
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", ASSEMBLY_NAME);
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", ASSEMBLY_NAME);
|
||||
//Then
|
||||
Assert.Equal(ASSEMBLY_NAME, serviceInfo.GetAssemblyName());
|
||||
serviceInfo.Dispose();
|
||||
@@ -119,8 +119,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
{
|
||||
//Given
|
||||
const string SERVICE_NAME = "Service";
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssemblyName");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssemblyName");
|
||||
//When
|
||||
serviceInfo.ServiceName = SERVICE_NAME;
|
||||
//Then
|
||||
@@ -132,8 +132,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void ServiceConsoleStream_ServiceNotStarted_NullReturned()
|
||||
{
|
||||
//Given
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//Then
|
||||
Assert.Null(serviceInfo.ServiceConsoleStream);
|
||||
serviceInfo.Dispose();
|
||||
@@ -143,8 +143,8 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
public void ServiceConsoleStream_ServiceStarted_StreamReturned()
|
||||
{
|
||||
//Given
|
||||
IGameService stubService = new FakeService();
|
||||
ServiceInfo serviceInfo = new ServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
IGameService stubService = new FakeGameService();
|
||||
GameServiceInfo serviceInfo = new GameServiceInfo(stubService, "FakeModule", "FakeAssembly");
|
||||
//When
|
||||
serviceInfo.Start();
|
||||
//Then
|
@@ -1,18 +1,18 @@
|
||||
using System.IO;
|
||||
using GameServiceWarden.Host.Modules;
|
||||
using GameServiceWarden.Core.Games;
|
||||
using GameServiceWarden.ModuleAPI;
|
||||
using Xunit;
|
||||
|
||||
namespace GameServiceWarden.Host.Tests.Modules
|
||||
namespace GameServiceWarden.Core.Tests.Modules.Games
|
||||
{
|
||||
public class ServiceManagerTest
|
||||
public class GameServiceManagerTest
|
||||
{
|
||||
[Fact]
|
||||
public void AddModule_NewManager_SuccessfulAddition()
|
||||
{
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -26,7 +26,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
{
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -41,7 +41,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string FAKE_SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
//When
|
||||
@@ -56,7 +56,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string FAKE_SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||
@@ -72,7 +72,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string FAKE_SERVICE_PREFIX = "FakeService_";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -93,11 +93,11 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule(
|
||||
new FakeConfigurable("A"),
|
||||
new FakeConfigurable("B"),
|
||||
new FakeConfigurable("C")
|
||||
new FakeGameConfigurable("A"),
|
||||
new FakeGameConfigurable("B"),
|
||||
new FakeGameConfigurable("C")
|
||||
);
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -114,9 +114,9 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule(
|
||||
new FakeConfigurable("A")
|
||||
new FakeGameConfigurable("A")
|
||||
);
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -132,7 +132,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -147,7 +147,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -163,7 +163,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -179,7 +179,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -196,7 +196,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
||||
@@ -218,7 +218,7 @@ namespace GameServiceWarden.Host.Tests.Modules
|
||||
//Given
|
||||
const string ASSEMBLY_NAME = "FakeAssembly";
|
||||
const string SERVICE_NAME = "FakeService";
|
||||
ServiceManager serviceManager = new ServiceManager();
|
||||
GameServiceManager serviceManager = new GameServiceManager();
|
||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||
//When
|
||||
serviceManager.AddModule(ASSEMBLY_NAME, stubGameServiceModule);
|
Reference in New Issue
Block a user