Skip to content

Commit

Permalink
tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPallister committed Apr 9, 2017
1 parent d751654 commit 1227ed4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace Rafty.ServiceDiscovery
{
public class ServiceRegistry : IServiceRegistry
public class InMemoryServiceRegistry : IServiceRegistry
{
public ServiceRegistry()
public InMemoryServiceRegistry()
{
Services = new List<Service>();
}
Expand Down
6 changes: 2 additions & 4 deletions test/Rafty.AcceptanceTests/AcceptanceTestsSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AcceptanceTestsSteps : IDisposable
public AcceptanceTestsSteps()
{
_serversInCluster = new InMemoryServersInCluster();
_serviceRegistry = new ServiceRegistry();
_serviceRegistry = new InMemoryServiceRegistry();
_servers = new List<ServerContainer>();
}

Expand Down Expand Up @@ -301,7 +301,7 @@ private async Task GivenAServerIsRunning(string baseUrl)
s.AddSingleton<IMessageBus, InMemoryBus>();
s.AddSingleton<IStateMachine, FakeStateMachine>();
s.AddSingleton<IServersInCluster, InMemoryServersInCluster>();
//s.AddSingleton<IServiceRegistry, ServiceRegistry>();
s.AddSingleton<IServiceRegistry>(_serviceRegistry);
})
.Configure(app =>
{
Expand All @@ -310,8 +310,6 @@ private async Task GivenAServerIsRunning(string baseUrl)
messageSender = app.ApplicationServices.GetRequiredService<IMessageSender>();
messageBus = app.ApplicationServices.GetRequiredService<IMessageBus>();
stateMachine = app.ApplicationServices.GetRequiredService<IStateMachine>();
//var _serviceRegistry = app.ApplicationServices.GetRequiredService<ILoggerFactory>();
//_serversInCluster = app.ApplicationServices.GetRequiredService<IServersInCluster>();

var result = app.UseRaftyForTesting(new Uri(baseUrl), messageSender, messageBus, stateMachine,
_serviceRegistry, loggerFactory, _serversInCluster);
Expand Down
12 changes: 6 additions & 6 deletions test/Rafty.UnitTests/ServiceRegistryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Rafty.UnitTests
public class ServiceRegistryTests
{
private RegisterService _registerService;
private readonly ServiceRegistry _serviceRegistry;
private readonly InMemoryServiceRegistry _inMemoryServiceRegistry;
private List<Service> _result;

public ServiceRegistryTests()
{
_serviceRegistry = new ServiceRegistry();
_inMemoryServiceRegistry = new InMemoryServiceRegistry();
}

[Fact]
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 1227ed4

Please sign in to comment.