public void PolarPlotsJson_ToModel_Converts_Values_From_PolarPlotter() { var slices = new List <PolarPlotSlice>(); var polarPlotter = TestUtilities.CreateMockInstance <IPolarPlotter>(); polarPlotter.Setup(r => r.TakeSnapshot()).Returns(slices); slices.Add(new PolarPlotSlice() { AltitudeLower = 111, AltitudeHigher = 222, PolarPlots = { { 7, new PolarPlot() { Angle = 7, Altitude = 150, Distance = 4, Latitude = 5, Longitude = 6, } } } }); var model = PolarPlotsJson.ToModel(44, polarPlotter.Object); Assert.AreEqual(44, model.FeedId); Assert.AreEqual(1, model.Slices.Count); Assert.AreEqual(111, model.Slices[0].StartAltitude); Assert.AreEqual(222, model.Slices[0].FinishAltitude); Assert.AreEqual(1, model.Slices[0].Plots.Count); Assert.AreEqual(5F, model.Slices[0].Plots[0].Latitude); Assert.AreEqual(6F, model.Slices[0].Plots[0].Longitude); }
[Route("PolarPlot.json")] // pre-version 3 route public PolarPlotsJson GetPolarPlot(int feedId = -1) { var feedManager = Factory.ResolveSingleton<IFeedManager>(); var feed = feedManager.GetByUniqueId(feedId, ignoreInvisibleFeeds: true); var plotter = feed?.AircraftList?.PolarPlotter; if(plotter != null && PipelineRequest.IsInternet) { var configuration = Factory.ResolveSingleton<ISharedConfiguration>().Get(); if(!configuration.InternetClientSettings.CanShowPolarPlots) { plotter = null; } } var result = plotter != null ? PolarPlotsJson.ToModel(feed.UniqueId, plotter) : new PolarPlotsJson() { FeedId = feedId, }; return result; }
public void PolarPlotsJson_ToModel_Returns_Null_If_Passed_Null() { Assert.IsNull(PolarPlotsJson.ToModel(1, null)); }