Ocelot/test/Ocelot.UnitTests/ServiceDiscovery/ServiceFabricServiceDiscoveryProviderTests.cs
Tom Pallister 463a7bdab4
Feature/websockets (#273)
* #212 - hacked websockets proxy together

* faffing around

* #212 hacking away :(

* #212 websockets proxy middleware working

* #212 map when for webockets working

* #212 some test refactor

* #212 temp commit

* #212 websockets proxy working, tests passing...need to do some tidying and write docs

* #212 more code coverage

* #212 docs for websockets

* #212 updated readme

* #212 tidying up after websockets refactoring

* #212 tidying up after websockets refactoring

* #212 tidying up after websockets refactoring

* stuck a warning in about logging levels into docs!
2018-03-23 18:01:02 +00:00

62 lines
1.9 KiB
C#

using Ocelot.ServiceDiscovery.Configuration;
using Ocelot.ServiceDiscovery.Providers;
namespace Ocelot.UnitTests.ServiceDiscovery
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Consul;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Logging;
using Ocelot.ServiceDiscovery;
using Ocelot.Values;
using Xunit;
using TestStack.BDDfy;
using Shouldly;
public class ServiceFabricServiceDiscoveryProviderTests
{
private ServiceFabricServiceDiscoveryProvider _provider;
private ServiceFabricConfiguration _config;
private string _host;
private string _serviceName;
private int _port;
private List<Service> _services;
[Fact]
public void should_return_service_fabric_naming_service()
{
this.Given(x => GivenTheFollowing())
.When(x => WhenIGet())
.Then(x => ThenTheServiceFabricNamingServiceIsRetured())
.BDDfy();
}
private void GivenTheFollowing()
{
_host = "localhost";
_serviceName = "OcelotServiceApplication/OcelotApplicationService";
_port = 19081;
}
private void WhenIGet()
{
_config = new ServiceFabricConfiguration(_host, _port, _serviceName);
_provider = new ServiceFabricServiceDiscoveryProvider(_config);
_services = _provider.Get().GetAwaiter().GetResult();
}
private void ThenTheServiceFabricNamingServiceIsRetured()
{
_services.Count.ShouldBe(1);
_services[0].HostAndPort.DownstreamHost.ShouldBe(_host);
_services[0].HostAndPort.DownstreamPort.ShouldBe(_port);
}
}
}