Esempio n. 1
0
        public void TestInitialise()
        {
            _OriginalFactory = Factory.TakeSnapshot();

            _ConfigurationStorage = TestUtilities.CreateMockSingleton <IConfigurationStorage>();
            _Configuration        = new Configuration();
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);

            _Plotter       = Factory.Singleton.Resolve <IPolarPlotter>();
            _SanityChecker = TestUtilities.CreateMockImplementation <IAircraftSanityChecker>();

            _CheckAltitudeResult = Certainty.ProbablyRight;
            _SanityChecker.Setup(r => r.CheckAltitude(It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <int>())).Returns((int id, DateTime date, int alt) => {
                return(_CheckAltitudeResult);
            });
            _SanityChecker.Setup(r => r.FirstGoodAltitude(It.IsAny <int>())).Returns(() => {
                throw new InvalidOperationException();
            });

            _CheckPositionResult = Certainty.ProbablyRight;
            _SanityChecker.Setup(r => r.CheckPosition(It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <double>(), It.IsAny <double>())).Returns((int id, DateTime date, double lat, double lng) => {
                return(_CheckPositionResult);
            });
            _SanityChecker.Setup(r => r.FirstGoodPosition(It.IsAny <int>())).Returns(() => {
                throw new InvalidOperationException();
            });

            _SavedPolarPlot = new SavedPolarPlot();
        }
Esempio n. 2
0
        /// <summary>
        /// Creates and returns a model from an <see cref="IPolarPlotter"/>.
        /// </summary>
        /// <param name="feedId"></param>
        /// <param name="polarPlotter"></param>
        /// <returns></returns>
        public static PolarPlotsJson ToModel(int feedId, IPolarPlotter polarPlotter)
        {
            PolarPlotsJson result = null;

            if (polarPlotter != null)
            {
                result = new PolarPlotsJson()
                {
                    FeedId = feedId,
                };
                result.Slices.AddRange(polarPlotter.TakeSnapshot().Select(r => PolarPlotsSliceJson.ToModel(r)));
            }

            return(result);
        }