Changed method names.
This commit is contained in:
parent
067c8f5824
commit
97967ce0c6
@ -25,14 +25,14 @@ namespace GameServiceWarden.Core.Games
|
|||||||
IReadOnlyDictionary<string, IGameServiceModule> assemblyModules = this.modules[assemblyName];
|
IReadOnlyDictionary<string, IGameServiceModule> assemblyModules = this.modules[assemblyName];
|
||||||
if (services.ContainsKey(serviceName)) throw new ArgumentException($"Service of Name \"{serviceName}\" already exists.");
|
if (services.ContainsKey(serviceName)) throw new ArgumentException($"Service of Name \"{serviceName}\" already exists.");
|
||||||
|
|
||||||
services.Add(serviceName, new GameServiceInfo(assemblyModules[moduleName].InstantiateGameService(services.GetPathForKey(serviceName), true), moduleName, assemblyName));
|
services.AddToPersistence(serviceName, new GameServiceInfo(assemblyModules[moduleName].InstantiateGameService(services.GetPathForKey(serviceName), true), moduleName, assemblyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteService(string serviceName)
|
public void DeleteService(string serviceName)
|
||||||
{
|
{
|
||||||
if (!services.ContainsKey(serviceName)) throw new KeyNotFoundException($"Service under name \"{serviceName}\" not found.");
|
if (!services.ContainsKey(serviceName)) throw new KeyNotFoundException($"Service under name \"{serviceName}\" not found.");
|
||||||
if (services[serviceName].GetServiceState() == ServiceState.Running) services[serviceName].Stop();
|
if (services[serviceName].GetServiceState() == ServiceState.Running) services[serviceName].Stop();
|
||||||
services.Remove(serviceName);
|
services.Delete(serviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetModuleNames()
|
public IEnumerable<string> GetModuleNames()
|
||||||
|
@ -106,7 +106,7 @@ namespace GameServiceWarden.Core.Persistence
|
|||||||
return mapDirectory + Path.DirectorySeparatorChar + key;
|
return mapDirectory + Path.DirectorySeparatorChar + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(string key, [MaybeNullWhen(false)] out IReadOnlyDictionary<string, IGameServiceModule> value)
|
public bool TryLoadValue(string key, [MaybeNullWhen(false)] out IReadOnlyDictionary<string, IGameServiceModule> value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,8 @@ namespace GameServiceWarden.Core.Persistence
|
|||||||
{
|
{
|
||||||
new V this[string key] { get; set; }
|
new V this[string key] { get; set; }
|
||||||
|
|
||||||
void Add(string key, V value);
|
void AddToPersistence(string key, V value);
|
||||||
void Clear();
|
void Clear();
|
||||||
bool Remove(string key);
|
bool Delete(string key);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,6 +24,6 @@ namespace GameServiceWarden.Core.Persistence
|
|||||||
/// <param name="key">The key to get the path for.</param>
|
/// <param name="key">The key to get the path for.</param>
|
||||||
/// <returns>A <see cref="string"/> representing the key.</returns>
|
/// <returns>A <see cref="string"/> representing the key.</returns>
|
||||||
string GetPathForKey(string key);
|
string GetPathForKey(string key);
|
||||||
bool TryGetValue(string key, [MaybeNullWhen(false)] out V value);
|
bool TryLoadValue(string key, [MaybeNullWhen(false)] out V value);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ namespace GameServiceWarden.Core.Tests.Modules
|
|||||||
|
|
||||||
IEnumerable<string> IReadOnlyPersistent<V>.Keys => backing.Keys;
|
IEnumerable<string> IReadOnlyPersistent<V>.Keys => backing.Keys;
|
||||||
|
|
||||||
public void Add(string key, V value)
|
public void AddToPersistence(string key, V value)
|
||||||
{
|
{
|
||||||
backing.Add(key, value);
|
backing.Add(key, value);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ namespace GameServiceWarden.Core.Tests.Modules
|
|||||||
return MapDirectory + Path.DirectorySeparatorChar + key;
|
return MapDirectory + Path.DirectorySeparatorChar + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(string key)
|
public bool Delete(string key)
|
||||||
{
|
{
|
||||||
return backing.Remove(key);
|
return backing.Remove(key);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ namespace GameServiceWarden.Core.Tests.Modules
|
|||||||
return backing.Remove(item);
|
return backing.Remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(string key, [MaybeNullWhen(false)] out V value)
|
public bool TryLoadValue(string key, [MaybeNullWhen(false)] out V value)
|
||||||
{
|
{
|
||||||
return backing.TryGetValue(key, out value);
|
return backing.TryGetValue(key, out value);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
//Then
|
//Then
|
||||||
@ -41,7 +41,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.DeleteService(FAKE_SERVICE_NAME);
|
serviceManager.DeleteService(FAKE_SERVICE_NAME);
|
||||||
@ -61,7 +61,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
new FakeGameConfigurable("C")
|
new FakeGameConfigurable("C")
|
||||||
);
|
);
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
//Then
|
//Then
|
||||||
@ -112,7 +112,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
new FakeGameConfigurable("A")
|
new FakeGameConfigurable("A")
|
||||||
);
|
);
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.SetServiceOptionValue(FAKE_SERVICE_NAME, "A", "Test");
|
serviceManager.SetServiceOptionValue(FAKE_SERVICE_NAME, "A", "Test");
|
||||||
@ -132,7 +132,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
//Then
|
//Then
|
||||||
@ -151,7 +151,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.StartService(FAKE_SERVICE_NAME);
|
serviceManager.StartService(FAKE_SERVICE_NAME);
|
||||||
@ -171,7 +171,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.StartService(FAKE_SERVICE_NAME);
|
serviceManager.StartService(FAKE_SERVICE_NAME);
|
||||||
@ -191,7 +191,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.StartService(FAKE_SERVICE_NAME);
|
serviceManager.StartService(FAKE_SERVICE_NAME);
|
||||||
@ -212,7 +212,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
serviceManager.StartService(FAKE_SERVICE_NAME);
|
serviceManager.StartService(FAKE_SERVICE_NAME);
|
||||||
@ -238,7 +238,7 @@ namespace GameServiceWarden.Core.Tests.Modules.Games
|
|||||||
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
Dictionary<string, IGameServiceModule> stubAssemblyModulesDictionary = new Dictionary<string, IGameServiceModule>();
|
||||||
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
IGameServiceModule stubGameServiceModule = new FakeGameServiceModule();
|
||||||
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
stubAssemblyModulesDictionary.Add(stubGameServiceModule.Name, stubGameServiceModule);
|
||||||
stubPersistentModuleDictionary.Add(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
stubPersistentModuleDictionary.AddToPersistence(ASSEMBLY_NAME, stubAssemblyModulesDictionary);
|
||||||
//When
|
//When
|
||||||
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
serviceManager.CreateService(FAKE_SERVICE_NAME, ASSEMBLY_NAME, stubGameServiceModule.Name);
|
||||||
//Then
|
//Then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user