From 1227ed45f30701d441e23e843ac88048762b7b99 Mon Sep 17 00:00:00 2001 From: TomPallister Date: Sun, 9 Apr 2017 16:55:38 +0100 Subject: [PATCH] tests passing --- ...ServiceRegistry.cs => InMemoryServiceRegistry.cs} | 4 ++-- test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs | 6 ++---- test/Rafty.UnitTests/ServiceRegistryTests.cs | 12 ++++++------ 3 files changed, 10 insertions(+), 12 deletions(-) rename src/Rafty/ServiceDiscovery/{ServiceRegistry.cs => InMemoryServiceRegistry.cs} (84%) diff --git a/src/Rafty/ServiceDiscovery/ServiceRegistry.cs b/src/Rafty/ServiceDiscovery/InMemoryServiceRegistry.cs similarity index 84% rename from src/Rafty/ServiceDiscovery/ServiceRegistry.cs rename to src/Rafty/ServiceDiscovery/InMemoryServiceRegistry.cs index d6814a8..163fbbc 100644 --- a/src/Rafty/ServiceDiscovery/ServiceRegistry.cs +++ b/src/Rafty/ServiceDiscovery/InMemoryServiceRegistry.cs @@ -3,9 +3,9 @@ namespace Rafty.ServiceDiscovery { - public class ServiceRegistry : IServiceRegistry + public class InMemoryServiceRegistry : IServiceRegistry { - public ServiceRegistry() + public InMemoryServiceRegistry() { Services = new List(); } diff --git a/test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs b/test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs index eff911a..b85aea1 100644 --- a/test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs +++ b/test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs @@ -32,7 +32,7 @@ public class AcceptanceTestsSteps : IDisposable public AcceptanceTestsSteps() { _serversInCluster = new InMemoryServersInCluster(); - _serviceRegistry = new ServiceRegistry(); + _serviceRegistry = new InMemoryServiceRegistry(); _servers = new List(); } @@ -301,7 +301,7 @@ private async Task GivenAServerIsRunning(string baseUrl) s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); - //s.AddSingleton(); + s.AddSingleton(_serviceRegistry); }) .Configure(app => { @@ -310,8 +310,6 @@ private async Task GivenAServerIsRunning(string baseUrl) messageSender = app.ApplicationServices.GetRequiredService(); messageBus = app.ApplicationServices.GetRequiredService(); stateMachine = app.ApplicationServices.GetRequiredService(); - //var _serviceRegistry = app.ApplicationServices.GetRequiredService(); - //_serversInCluster = app.ApplicationServices.GetRequiredService(); var result = app.UseRaftyForTesting(new Uri(baseUrl), messageSender, messageBus, stateMachine, _serviceRegistry, loggerFactory, _serversInCluster); diff --git a/test/Rafty.UnitTests/ServiceRegistryTests.cs b/test/Rafty.UnitTests/ServiceRegistryTests.cs index b73a1e2..892c6c0 100644 --- a/test/Rafty.UnitTests/ServiceRegistryTests.cs +++ b/test/Rafty.UnitTests/ServiceRegistryTests.cs @@ -11,12 +11,12 @@ namespace Rafty.UnitTests public class ServiceRegistryTests { private RegisterService _registerService; - private readonly ServiceRegistry _serviceRegistry; + private readonly InMemoryServiceRegistry _inMemoryServiceRegistry; private List _result; public ServiceRegistryTests() { - _serviceRegistry = new ServiceRegistry(); + _inMemoryServiceRegistry = new InMemoryServiceRegistry(); } [Fact] @@ -46,12 +46,12 @@ private void GivenAServiceToRegister(RegisterService registerService) private void WhenIRegisterTheService() { - _serviceRegistry.Register(_registerService); + _inMemoryServiceRegistry.Register(_registerService); } private void ThenItIsRegistered() { - _serviceRegistry.Services.Count.ShouldBe(1); + _inMemoryServiceRegistry.Services.Count.ShouldBe(1); } private void GivenAListOfRegisteredServices() @@ -60,13 +60,13 @@ private void GivenAListOfRegisteredServices() for (int i = 0; i < 5; i++) { var registerService = new RegisterService(RaftyServiceDiscoveryName.Get(), Guid.NewGuid(), new Uri($"www.rafty.co.uk:123{i}")); - _serviceRegistry.Register(registerService); + _inMemoryServiceRegistry.Register(registerService); } } private void WhenIGetTheRegisteredServices() { - _result = _serviceRegistry.Get(RaftyServiceDiscoveryName.Get()); + _result = _inMemoryServiceRegistry.Get(RaftyServiceDiscoveryName.Get()); } private void ThenTheServicesAreReturned()