public void PolarPlotsSliceJson_ToModel_Converts_PolarPlotSlice() { var polarPlotSlice = new PolarPlotSlice() { AltitudeLower = 12000, AltitudeHigher = 13499, }; polarPlotSlice.PolarPlots.Add(10, new PolarPlot() { Altitude = 12000, Angle = 10, Distance = 0, Latitude = 1.23, Longitude = 4.56, }); var model = PolarPlotsSliceJson.ToModel(polarPlotSlice); Assert.AreEqual(12000, model.StartAltitude); Assert.AreEqual(13499, model.FinishAltitude); Assert.AreEqual(1, model.Plots.Count); Assert.AreEqual(1.23F, model.Plots[0].Latitude); Assert.AreEqual(4.56F, model.Plots[0].Longitude); }
protected override bool DoHandleRequest(IWebServer server, RequestReceivedEventArgs args) { var result = false; if (args.PathAndFile.Equals("/PolarPlot.json", StringComparison.OrdinalIgnoreCase)) { result = true; var allowRequest = _InternetClientCanShowPolarPlot || !args.IsInternetRequest; var feedId = allowRequest ? QueryInt(args, "feedId", -1) : -1; var json = new PolarPlotsJson() { FeedId = feedId, }; if (allowRequest) { var feed = _FeedManager.GetByUniqueId(feedId, ignoreInvisibleFeeds: true); var polarPlotter = feed == null || feed.AircraftList == null ? null : feed.AircraftList.PolarPlotter; if (polarPlotter != null) { foreach (var slice in polarPlotter.TakeSnapshot()) { var jsonSlice = new PolarPlotsSliceJson() { StartAltitude = slice.AltitudeLower, FinishAltitude = slice.AltitudeHigher, }; json.Slices.Add(jsonSlice); foreach (var kvp in slice.PolarPlots.OrderBy(r => r.Key)) { var plot = kvp.Value; jsonSlice.Plots.Add(new PolarPlotJson() { Latitude = (float)plot.Latitude, Longitude = (float)plot.Longitude, }); } } } } Responder.SendJson(args.Request, args.Response, json, null, null); } return(result); }
public void PolarPlotsSliceJson_ToModel_Returns_Plots_In_Angle_Order() { var polarPlotSlice = new PolarPlotSlice(); polarPlotSlice.PolarPlots.Add(99, new PolarPlot() { Angle = 99, Latitude = 99, Longitude = 99, }); polarPlotSlice.PolarPlots.Add(30, new PolarPlot() { Angle = 30, Latitude = 30, Longitude = 30, }); polarPlotSlice.PolarPlots.Add(45, new PolarPlot() { Angle = 45, Latitude = 45, Longitude = 45, }); var model = PolarPlotsSliceJson.ToModel(polarPlotSlice); Assert.AreEqual(30F, model.Plots[0].Latitude); Assert.AreEqual(45F, model.Plots[1].Latitude); Assert.AreEqual(99F, model.Plots[2].Latitude); }
public void PolarPlotsSliceJson_ToModel_Returns_Null_If_Passed_Null() { Assert.IsNull(PolarPlotsSliceJson.ToModel(null)); }
public void TestInitialise() { _Json = new PolarPlotsSliceJson(); }