public void EqualityTestOnNonEqualObjectsTest()
        {
            //objects should be equal

            var sport = new SportOverview()
            {
                InErrorState = 30,
                InPlay       = 4,
                InPreMatch   = 5,
                InSetup      = 7,
                Name         = "Tennis",
                Total        = 3 + 4 + 5
            };

            var secondSport = new SportOverview()
            {
                InErrorState = 3,
                InPlay       = 4,
                InPreMatch   = 5,
                Name         = "Tennis",
                Total        = 3 + 4 + 5
            };

            sport.Equals(secondSport).Should().BeFalse();
        }
        public void EqualityTestOnNonEqualObjectsTest()
        {
            //objects should be equal

            var sport = new SportOverview()
            {
                InErrorState = 30,
                InPlay = 4,
                InPreMatch = 5,
                InSetup = 7,
                Name = "Tennis",
                Total = 3 + 4 + 5
            };

            var secondSport = new SportOverview()
            {
                InErrorState = 3,
                InPlay = 4,
                InPreMatch = 5,
                Name = "Tennis",
                Total = 3 + 4 + 5
            };

            sport.Equals(secondSport).Should().BeFalse();
        }
Esempio n. 3
0
        private void UpdateSportDetails(string sportName)
        {
            var sportOverview = new SportOverview {
                Name = sportName
            };

            var fixturesForSport = _fixturesOverview.Values.Where(f =>
                                                                  f.Sport == sportOverview.Name &&
                                                                  (f.ListenerOverview.IsDeleted.HasValue && !f.ListenerOverview.IsDeleted.Value || !f.ListenerOverview.IsDeleted.HasValue))
                                   .ToList();

            sportOverview.Total        = fixturesForSport.Count;
            sportOverview.InErrorState = fixturesForSport.Count(f => f.ListenerOverview.IsErrored.HasValue && f.ListenerOverview.IsErrored.Value);

            var groupedByMatchStatus = fixturesForSport
                                       .GroupBy(f => f.ListenerOverview.MatchStatus, f => f.ListenerOverview.MatchStatus)
                                       .Where(g => g.Key.HasValue).ToDictionary(g => g.Key.Value, g => g.Count());

            if (groupedByMatchStatus.Any())
            {
                sportOverview.InPlay = groupedByMatchStatus.ContainsKey(MatchStatus.InRunning)
                    ? groupedByMatchStatus[MatchStatus.InRunning]
                    : 0;

                sportOverview.InPreMatch = groupedByMatchStatus.ContainsKey(MatchStatus.Prematch)
                    ? groupedByMatchStatus[MatchStatus.Prematch]
                    : 0;

                sportOverview.InSetup = groupedByMatchStatus.ContainsKey(MatchStatus.Setup)
                    ? groupedByMatchStatus[MatchStatus.Setup]
                    : 0;
            }

            if (_sportsOverview.ContainsKey(sportOverview.Name) &&
                _sportsOverview[sportOverview.Name].Equals(sportOverview))
            {
                return;
            }

            _sportsOverview[sportOverview.Name] = sportOverview;

            _streamingService.OnSportUpdate(sportOverview.ToServiceModel());
        }
        private void UpdateSportDetails(string sportName)
        {
            var sportOverview = new SportOverview();
            sportOverview.Name = sportName;


            var fixturesForSport = _fixtures.Values.Where(f =>
                                                            f.Sport == sportOverview.Name
                                                            && (f.ListenerOverview.IsDeleted.HasValue && !f.ListenerOverview.IsDeleted.Value || !f.ListenerOverview.IsDeleted.HasValue))
                                                            .ToList();
            sportOverview.Total = fixturesForSport.Count;
            sportOverview.InErrorState = fixturesForSport.Count(f => f.ListenerOverview.IsErrored.HasValue && f.ListenerOverview.IsErrored.Value);

            var groupedByMatchStatus = fixturesForSport
                .GroupBy(f => f.ListenerOverview.MatchStatus, f => f.ListenerOverview.MatchStatus)
                .Where(g => g.Key.HasValue).ToDictionary(g => g.Key.Value, g => g.Count());

            if (groupedByMatchStatus.Any())
            {

                sportOverview.InPlay = groupedByMatchStatus.ContainsKey(MatchStatus.InRunning)
                    ? groupedByMatchStatus[MatchStatus.InRunning]
                    : 0;

                sportOverview.InPreMatch = groupedByMatchStatus.ContainsKey(MatchStatus.Prematch)
                    ? groupedByMatchStatus[MatchStatus.Prematch]
                    : 0;

                sportOverview.InSetup = groupedByMatchStatus.ContainsKey(MatchStatus.Setup)
                    ? groupedByMatchStatus[MatchStatus.Setup]
                    : 0;
            }

            if (_sportOverviews.ContainsKey(sportOverview.Name) &&
                _sportOverviews[sportOverview.Name].Equals(sportOverview))
            {
                return;
            }

            _sportOverviews[sportOverview.Name] = sportOverview;
            _sportTracker.OnNext(sportOverview);

        }