Ejemplo n.º 1
0
        /// <summary>
        /// Derives the series resolution from the given time frame. The UI makes sure
        /// that when the customer requests data for the year graph, the @from and to are
        /// in different months. Otherwise the @from and to are in the same month.
        /// </summary>
        /// <param name="from">The start of the time frame</param>
        /// <param name="to">The end of the time frame</param>
        /// <returns>Series resolution</returns>
        private SeriesResolution DeriveResolution(DateTime from, DateTime to)
        {
            var span = to - from;

            _logger.LogDebug($"Series request span from and to: {span}");
            return(_resolutionCalculator.Calculate(from, to));
        }
        public void GetSingleOriginalResolutionTest()
        {
            //Arrange
            const int width      = 150;
            const int height     = 180;
            var       calculator = new ResolutionCalculator();

            //Act
            var resolutionList = calculator.Calculate(width, height);

            //Assert
            Assert.AreEqual(1, resolutionList.Count);
            Assert.AreEqual(width, resolutionList[0].Width);
            Assert.AreEqual(height, resolutionList[0].Height);
        }
        public void GetSingleOriginalResolutionTest()
        {
            //Arrange
            const int width = 150;
            const int height = 180;
            var calculator = new ResolutionCalculator(width, height);

            //Act
            var resolutionList = calculator.Calculate();

            //Assert
            Assert.AreEqual(1, resolutionList.Count);
            Assert.AreEqual(width, resolutionList[0].Width);
            Assert.AreEqual(height, resolutionList[0].Height);
        }
        public void GetAllResolutionsForHDVideoTest()
        {
            //Arrange
            const int width              = 1920;
            const int height             = 1080;
            var       calculator         = new ResolutionCalculator();
            var       expectedResolution = new List <IVideoSize>()
            {
                new VideoSize(640, 360),
                new VideoSize(854, 480),
                new VideoSize(1280, 720),
                new VideoSize(1920, 1080)
            };

            //Act
            var resolutionList = calculator.Calculate(width, height);

            //Assert
            Assert.IsTrue(expectedResolution.All(videoSize => resolutionList.Any(s => s.Width == videoSize.Width && s.Height == videoSize.Height)));
        }
        public void GetFourQuantityResolutionTest()
        {
            //Arrange
            const int width = 1920;
            const int height = 1080;
            var calculator = new ResolutionCalculator(width, height);
            var expectedResolution = new List<VideoSize>()
                                         {
                                             new VideoSize(640, 360),
                                             new VideoSize(854, 480),
                                             new VideoSize(1280, 720),
                                             new VideoSize(1920, 1080)
                                         };

            //Act
            var resolutionList = calculator.Calculate();

            //Assert
            Assert.IsTrue(expectedResolution.All(videoSize => resolutionList.Any(s => s.Width == videoSize.Width && s.Height == videoSize.Height)));
        }