public void GetRouteSegments_returns_correct_segments() { var sut = new RouteDataProvider(this.repo); var data = sut.GetRouteSegments(0); data.Count.ShouldBeGreaterThan(5); var first = data.First(); first.SegmentId.ShouldBe(0); first.Name.ShouldBe("Alexandria Castle"); first.Subname.ShouldBeNull(); first.Characters.Length.ShouldBe(1); first.Characters.First().ShouldBe(Character.Zidane); first.Position.ShouldBe(0); var third = data.Skip(2).First(); third.SegmentId.ShouldBe(2); third.Name.ShouldBe("Evil Forest"); third.Subname.ShouldBe("After Prison Cage"); third.Characters.Length.ShouldBe(3); third.Characters.ShouldContain(Character.Zidane); third.Characters.ShouldContain(Character.Vivi); third.Characters.ShouldContain(Character.Steiner); third.Position.ShouldBe(20); }
void button1_Click(object sender, System.EventArgs e) { wayPoints.Clear(); foreach (object point in listBox1.SelectedItems) { wayPoints.Add(new RouteWaypoint("", point as GeoPoint)); } RouteDataProvider.CalculateRoute(wayPoints); }
public void should_ignore_incorrect_codeRRContext() { var context = new ErrorReporterContext(this, new Exception()); var sut = new RouteDataProvider(); var result = sut.Collect(context); result.Should().BeNull(); }
public void GetRoutes_returns_default_route() { var sut = new RouteDataProvider(this.repo); var data = sut.GetRoutes(); data.Count.ShouldBeGreaterThan(0); data.First().RouteId.ShouldBe(0); data.First().Name.ShouldBe("Default"); }
public void should_return_null_when_the_collection_is_empty() { var httpContext = Substitute.For <HttpContextBase>(); var context = new AspNetMvcContext(this, new Exception(), httpContext); context.RouteData = new RouteData(); var sut = new RouteDataProvider(); var result = sut.Collect(context); result.Should().BeNull(); }
public void should_include_included_items() { var httpContext = Substitute.For <HttpContextBase>(); var context = new AspNetMvcContext(this, new Exception(), httpContext); var routeData = new RouteData(); routeData.DataTokens.Add("MyToken", "Value1"); routeData.Values.Add("MyValue", "Value2"); context.RouteData = routeData; var sut = new RouteDataProvider(); var result = sut.Collect(context); result.Property("DataToken[\"MyToken\"]").Should().Be("Value1"); result.Property("Values[\"MyValue\"]").Should().Be("Value2"); }
private HttpResponseMessage LogResponse(string apikey, Task <HttpResponseMessage> response, HttpRequestMessage request) { if (string.IsNullOrEmpty(apikey)) { return(response.Result); } var db = Redis.GetDatabase(); db.StringIncrement(apikey, flags: CommandFlags.FireAndForget); db.StringSet(apikey + ":time", DateTime.UtcNow.Ticks, flags: CommandFlags.FireAndForget); db.StringIncrement(apikey + ":today", flags: CommandFlags.FireAndForget); db.KeyExpire(apikey + ":today", CalculateTimeUntil(DateTime.Now, Today)); db.StringIncrement(apikey + ":month", flags: CommandFlags.FireAndForget); db.KeyExpire(apikey + ":month", CalculateTimeUntil(DateTime.Now, Month)); db.StringIncrement(apikey + ":minute", flags: CommandFlags.FireAndForget); var ttl = db.KeyTimeToLive(apikey + ":minute"); if (!ttl.HasValue || ttl.Value == TimeSpan.MinValue) { db.KeyExpire(apikey + ":minute", TimeSpan.FromMinutes(1)); } var routeData = RouteDataProvider.GetRouteData(request); if (string.IsNullOrEmpty(routeData.Controller) || string.IsNullOrEmpty(routeData.Action) || string.IsNullOrEmpty(apikey)) { return(response.Result); } var geocodingClient = string.Empty; var clientVersion = string.Empty; if (request.Headers.TryGetValues("x-agrc-geocode-client", out var client)) { geocodingClient = client.First(); } if (request.Headers.TryGetValues("x-agrc-geocode-client-version", out var version)) { clientVersion = version.First(); } switch (routeData.Controller.ToUpper()) { case "GEOCODE": { LogRequest("geocode", apikey, db, geocodingClient, clientVersion); break; } case "INFO": { LogRequest("info", apikey, db); break; } case "SEARCH": { LogRequest("search", apikey, db); break; } } return(response.Result); }