public void TestNoDaysInCollection()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
            });

            Assert.ThrowsException <InvalidOperationException>(() => collection.GetHighestInMonth(1));
        }
Exemplo n.º 2
0
        public void TestOneDataPoint()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 50, 40)
            });

            Assert.AreEqual(50.0, collection.GetAverageHigh());
        }
        public void TestNoDaysInMonth()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Parse("2/2/2007"), 0, -10)
            });

            Assert.ThrowsException <InvalidOperationException>(() => collection.GetHighestInMonth(1));
        }
Exemplo n.º 4
0
        public void TestNoDaysInCollection()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo>
            {
            });

            Assert.ThrowsException <InvalidOperationException>(() => collection.FindLowestHighTemps());
        }
        public void FromOneWeatherInfo()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 50, 40)
            });

            Assert.AreEqual(40, collection.FindWithLowestTemp().First().LowTemp);
        }
Exemplo n.º 6
0
        public void TestTwoDataPoints()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 0, -10),
                new WeatherInfo(DateTime.Today, 100, 90)
            });

            Assert.AreEqual(50, collection.GetAverageHigh());
        }
        public void FromTwoWeatherInfo()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 0, -10),
                new WeatherInfo(DateTime.Today, 100, -9)
            });

            Assert.AreEqual(-10, collection.FindWithLowestTemp().First().LowTemp);
        }
Exemplo n.º 8
0
        public void TestManyDataPointsDecimalAnswer()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), -2, -10),
                new WeatherInfo(DateTime.Today.AddDays(-2), 32, -10),
                new WeatherInfo(DateTime.Today, 118, 90)
            });

            Assert.AreEqual(49.33, collection.GetAverageHigh(), .009);
        }
        public void FromManyWeatherInfo()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 0, -10),
                new WeatherInfo(DateTime.Today.AddDays(-1), 99, -10),
                new WeatherInfo(DateTime.Today, 100, -10)
            });

            Assert.AreEqual(100, collection.FindWithHighestTemp().First().HighTemp);
        }
Exemplo n.º 10
0
        public void TestManyDataPointsDecimalAnswer()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                new WeatherInfo(DateTime.Today.AddDays(-3), 5, 2),
                new WeatherInfo(DateTime.Today, 100, 97),
                new WeatherInfo(DateTime.Today, 100, 43)
            });

            Assert.AreEqual(47.33, collection.GetAverageLow(), .009);
        }
        public void TestOneDaysInMonth()
        {
            var testWeatherInfo = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);
            var collection      = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testWeatherInfo
            });
            var result   = collection.GetHighestInMonth(1);
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testWeatherInfo
            });

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        public void TestTwoDaysInMonthLowBoundry()
        {
            var testinfo1S = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);
            var testinfo2  = new WeatherInfo(DateTime.Parse("1/2/2007"), -1, -10);
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S
            });
            var result = collection.GetHighestInMonth(1);

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        public void TestTwoDaysInMonthEquals()
        {
            var testinfo1S = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, 0);
            var testinfo2S = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, 0);
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S
            });
            var result = collection.FindHighestLowTemps();

            Assert.IsTrue(expected.SequenceEqual(result));
        }
Exemplo n.º 14
0
        public void TestManyDaysInMonthTempertureSequenceSecondIsLowest()
        {
            var testinfo1  = new WeatherInfo(DateTime.Parse("1/2/2007"), 1, -10);
            var testinfo2S = new WeatherInfo(DateTime.Parse("1/2/2007"), -1, -10);
            var testinfo3  = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);

            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1,
                testinfo2S,
                testinfo3
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo2S
            });
            var result = collection.FindLowestHighTemps();

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        public void TestManyDaysInMonthTempertureSequence()
        {
            var testinfo1  = new WeatherInfo(DateTime.Parse("1/2/2007"), -1, -10);
            var testinfo2  = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);
            var testinfo3S = new WeatherInfo(DateTime.Parse("1/2/2007"), 1, -10);

            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1,
                testinfo2,
                testinfo3S
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo3S
            });
            var result = collection.GetHighestInMonth(1);

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        public void TestManyDaysInMonthTempertureSequenceFirstIsHighest()
        {
            var testinfo1S = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, 1);
            var testinfo2  = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, 0);
            var testinfo3  = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, -1);

            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2,
                testinfo3
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S
            });
            var result = collection.FindHighestLowTemps();

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        public void TestManyDaysInOutsidemonthBehindInTime()
        {
            var testinfo1S = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);
            var testinfo2S = new WeatherInfo(DateTime.Parse("1/2/2007"), 0, -10);
            var testinfo3  = new WeatherInfo(DateTime.Parse("2/1/2007"), 0, -10);

            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S,
                testinfo3
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S
            });
            var result = collection.GetHighestInMonth(1);

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        private async Task <WeatherInfoCollection> performMergeTypeImportAsync(
            WeatherInfoCollection newWeatherInfoCollection)
        {
            var matchedDates = newWeatherInfoCollection.Where(weatherInfo =>
                                                              ActiveWeatherInfoCollection.Active.Any(activeWeatherInfo =>
                                                                                                     activeWeatherInfo.Date == weatherInfo.Date));
            var unmatchedDates = newWeatherInfoCollection.Where(weatherInfo =>
                                                                ActiveWeatherInfoCollection.Active.All(activeWeatherInfo =>
                                                                                                       activeWeatherInfo.Date != weatherInfo.Date));

            await this.requestUserMergePreference(matchedDates);

            foreach (var current in unmatchedDates)
            {
                ActiveWeatherInfoCollection.Active.Add(current);
            }

            return(ActiveWeatherInfoCollection.Active);
        }
        public void TestManyDaysInMonthDuplicate()
        {
            var testinfo1S = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, -1);
            var testinfo2S = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, -1);
            var testinfo3  = new WeatherInfo(DateTime.Parse("1/2/2007"), 10, 0);

            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S,
                testinfo3
            });
            var expected = new WeatherInfoCollection("Test1", new List <WeatherInfo> {
                testinfo1S,
                testinfo2S
            });
            var result = collection.GetLowestInMonth(1);

            Assert.IsTrue(expected.SequenceEqual(result));
        }
        /// <summary>
        ///     Gets the day temperature list.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="weatherInfoList">The temporary list.</param>
        /// <returns></returns>
        public WeatherInfoCollection GetWeatherInfoCollection(string name, IList <string> weatherInfoList)
        {
            var data = new List <WeatherInfo>();

            foreach (var currentDateData in weatherInfoList)
            {
                var splitLine    = currentDateData.Split(',');
                var currentIndex = weatherInfoList.IndexOf(currentDateData);

                if (this.isValidData(splitLine, currentIndex))
                {
                    data.Add(this.parseLine(splitLine));
                }
            }

            var newCollection = new WeatherInfoCollection(name, data);

            ActiveWeatherInfoCollection.Active = newCollection;
            return(newCollection);
        }
 public static ObservableCollection <WeatherInfo> ToObservableCollection(this WeatherInfoCollection collection)
 {
     return(new ObservableCollection <WeatherInfo>(collection));
 }
Exemplo n.º 22
0
        public void TestZeroDataPoints()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo>());

            Assert.AreEqual(int.MaxValue, collection.GetAverageHigh());
        }
Exemplo n.º 23
0
        public void TestZeroDataPoints()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo>());

            Assert.AreEqual(double.MinValue, collection.GetAverageLow());
        }
        public void FromZeroWeatherInfo()
        {
            var collection = new WeatherInfoCollection("Test1", new List <WeatherInfo>());

            Assert.ThrowsException <InvalidOperationException>(() => collection.FindWithLowestTemp().First().HighTemp);
        }