public static Match Replay(string matchId)
        {
            var allEvents = EventRepository.All(matchId);

            if (allEvents.Count == 0)
            {
                return(null);
            }

            var match = new Match();

            foreach (var e in allEvents)
            {
                var whatHappened = (EventType)Enum.Parse(typeof(EventType), e.Action);
                switch (whatHappened)
                {
                case EventType.Created:
                    match = new Match(e.MatchId, e.Team1, e.Team2);
                    break;

                case EventType.Start:
                    match.Start();
                    break;

                case EventType.End:
                    match.Finish();
                    break;

                case EventType.NewPeriod:
                    match.StartPeriod();
                    break;

                case EventType.EndPeriod:
                    match.EndPeriod();
                    break;

                case EventType.Goal1:
                    match.Goal(TeamId.Home);            // Should add player reference too
                    break;

                case EventType.Goal2:
                    match.Goal(TeamId.Visitors);        // Should add player reference too
                    break;

                case EventType.Timeout1:
                    match.Timeout(TeamId.Home);
                    break;

                case EventType.Timeout2:
                    match.Timeout(TeamId.Visitors);
                    break;

                case EventType.Resume:
                    match.Resume();
                    break;
                }
            }
            return(match);
        }
        public void All_Returns_Correct_Result(
            EventRepository sut, IEnumerable<Event> data )
        {
            Database.Open().Events.Insert(data);

            var result = sut.All();
            result.ShouldAllBeEquivalentTo(data);
        }
示例#3
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            NewEventForm.Visibility = Visibility.Collapsed;
            repo = new EventRepository();
            int     odometer = Int32.Parse(Odometer.Text);
            decimal gall     = Convert.ToDecimal(Gallons.Text);
            decimal cost     = Convert.ToDecimal(CostofFillUp.Text);
            string  date     = EventDate.SelectedDate.ToString();

            repo.Add(new Event(odometer, gall, cost, date));
            FillUpList.DataContext = repo.All();
            MPG.DataContext        = repo.CalculateAverage();
            Odometer.Text          = "";
            Gallons.Text           = "";
            CostofFillUp.Text      = "";
            EventDate.Text         = "";
        }
示例#4
0
 public IEnumerable <Event> All(string partionKey)
 {
     return(_eventRepository.All(partionKey));
 }
示例#5
0
 public List <Event> AllEvents()
 {
     return(_er.All());
 }