Example #1
0
        public ISet <DayOfWeek> EvaluateMswData(MswSwellData mswSwellData, MswSurfSpot mswSurfSpot)
        {
            ISet <DayOfWeek> swellDates = new HashSet <DayOfWeek>();

            foreach (var day in mswSwellData)
            {
                foreach (var hour in day.Value)
                {
                    if (HasDaylight(hour.Key) && hour.Value.FullStars >= mswSurfSpot.FullStars && hour.Value.BlurredStars >= mswSurfSpot.BlurredStars)
                    {
                        swellDates.Add(hour.Value.Timestamp.DayOfWeek);
                    }
                }
            }

            return(swellDates);
        }
Example #2
0
        public void Test_GetSwellDataFromFile_VieuxBoucau()
        {
            // Arrange
            IMswDataProvider mswDataProvider = new MswDataProvider();

            // Act
            MswSwellData mswSwellData = mswDataProvider.GetMswSwellDataFromFile(MswVieuxBoucauForecast);

            // Assert
            mswSwellData.Count.Should().Be(7);

            for (int day = 1; day <= mswSwellData.Count; day++)
            {
                bool hasValueForDay = mswSwellData.TryGetValue(day, out MswDailySwellData mswDailySwellData);
                hasValueForDay.Should().BeTrue();

                AssertMswDailySwellData(day, mswDailySwellData);
            }
        }
Example #3
0
        private async Task <List <Message> > CheckMswSpots()
        {
            var messages = new List <Message>();
            var mswSpots = await _databaseService.GetAllMswSurfSpotsAsync();

            foreach (var mswSpot in mswSpots)
            {
                MswSwellData mswSwellData = await _mswDataProvider.GetMswSwellDataFromWeb(mswSpot.Url);

                ISet <DayOfWeek> dates = _mswEvaluator.EvaluateMswData(mswSwellData, mswSpot);
                if (dates.Count != 0)
                {
                    messages.Add(new Message()
                    {
                        Dates = dates, SpotName = mswSpot.Name, SpotUrl = mswSpot.Url
                    });
                }
            }
            return(messages);
        }