Пример #1
0
		public void Flush_And_Hydrate_Routes()
		{
			var folder = System.Configuration.ConfigurationManager.AppSettings["repositoryFolder"];

			var list = from f in System.IO.Directory.GetFiles(folder, "*.route.json")
					   select f;

			foreach (var file in list)
			{
				System.IO.File.Delete(file);
			}

			var route = new RoutesHostServer.Models.Route();
			route.ApiKey = Guid.NewGuid().ToString();
			route.ServiceName = "Test";
			route.WebApiAddress = "http://test.com";

			RoutesHostServer.Services.RoutesProvider.Current.Register(route);

			RoutesHostServer.Services.RoutesProvider.Current.Flush(folder);

			RoutesHostServer.Services.RoutesProvider.Current.Hydrate(folder);

			var address = RoutesHostServer.Services.RoutesProvider.Current.Resolve(route.ApiKey, route.ServiceName);

			Check.That(address).IsEqualTo(route.WebApiAddress);
		}
Пример #2
0
		public Guid Register(Route clientRoute)
		{
			var serverRoute = new RoutesHostServer.Models.Route();
			serverRoute.ApiKey = clientRoute.ApiKey;
			serverRoute.Priority = clientRoute.Priority;
			serverRoute.ServiceName = clientRoute.ServiceName;
			serverRoute.WebApiAddress = clientRoute.WebApiAddress;
			serverRoute.PingPath = clientRoute.PingPath;
			serverRoute.MachineName = clientRoute.MachineName;
			var result = RoutesHostServer.Services.RoutesProvider.Current.Register(serverRoute);
			return result;
		}
Пример #3
0
		public void Register_Existing_Route_With_Same_Priority()
		{
			var controller = new RoutesHostServer.Controllers.RoutesApiController();

			var route = new RoutesHostServer.Models.Route();
			route.ApiKey = Guid.NewGuid().ToString();
			route.ServiceName = "Test";
			route.WebApiAddress = "http://test.com";
			controller.Register(route);
			controller.Register(route);

			var result = controller.Resolve(route.ApiKey, route.ServiceName);
			Check.That(result.Address).IsEqualTo(route.WebApiAddress);
		}
Пример #4
0
		public void Add_Routes_With_Priorities_And_Unregister_First()
		{
			var controller = new RoutesHostServer.Controllers.RoutesApiController();

			var route = new RoutesHostServer.Models.Route();
			route.ApiKey = Guid.NewGuid().ToString();
			route.ServiceName = "Test";
			route.WebApiAddress = "http://test.com";
			controller.Register(route);

			var lessRoute =(RoutesHostServer.Models.Route)route.Clone();
			lessRoute.Priority = 2;
			controller.Register(lessRoute);

			var result = controller.Resolve(route.ApiKey, route.ServiceName);

			Check.That(result.Address).IsEqualTo(route.WebApiAddress);

			controller.UnRegister(route.Id);

			result = controller.Resolve(route.ApiKey, route.ServiceName);

			Check.That(result.Address).IsNotNull();
		}