public void GetServer_CalledTwoTimes_ServerShouldBeTheSame() { var mockedModsetProvider = CreateMockedModsetProvider(); var dedicatedServerFactoryMock = CreateDedicatedServerFactoryMock(ServerPort); var serverProvider = new ServerProvider( mockedModsetProvider, PrepareProcessDiscoverer(), dedicatedServerFactoryMock.Object, _logger); var firstDedicatedServer = serverProvider.GetServer(ServerPort, _modset); var secondDedicatedServer = serverProvider.GetServer(ServerPort, _modset); dedicatedServerFactoryMock .Verify(x => x.CreateDedicatedServer(ServerPort, _modset, 1), Times.Once); firstDedicatedServer.Should().Be(secondDedicatedServer); }
public void GetServer_CalledTwoTimesFirstServerDisposed_NewServerReturned() { var mockedModsetProvider = CreateMockedModsetProvider(); var dedicatedServerFactoryMock = CreateDedicatedServerFactoryMock(ServerPort); var serverProvider = new ServerProvider( mockedModsetProvider, PrepareProcessDiscoverer(), dedicatedServerFactoryMock.Object, _logger); var firstDedicatedServer = serverProvider.GetServer(ServerPort, _modset); firstDedicatedServer.Dispose(); var secondDedicatedServer = serverProvider.GetServer(ServerPort, _modset); dedicatedServerFactoryMock .Verify(x => x.CreateDedicatedServer(ServerPort, _modset, 1), Times.Exactly(2)); firstDedicatedServer.Should().NotBe(secondDedicatedServer); }
public override async Task InvokeAsync(ClientActionContext context) { if (context.ServerConnection == null) { context.ServerConnection = ServerProvider.GetServer(); } context.GetRequestOrThrow().RequestUri = EndpointProvider.GetEndpoint(context.ServerConnection.Server, context.Contract, context.Action); try { await Next(context).ConfigureAwait(false); } catch (HttpRequestException) { ServerProvider.OnServerUnavailable(context.Request.RequestUri); throw; } }