Пример #1
0
        private void createButton_Click(object sender, EventArgs e)
        {
            ObserverCreationForm modalDialogForm = new ObserverCreationForm();
            modalDialogForm.Text = "New Observer";
            modalDialogForm.ObserverTitle = string.Format("Observer #{0}", manager.Observers.Count + 1);
            if (modalDialogForm.ShowDialog() == DialogResult.OK)
            {
                RacerObserver observer;

                if (modalDialogForm.Type == ObserverType.Support)
                    observer = new SupportObserver(modalDialogForm.To, modalDialogForm.Header, modalDialogForm.Footer, modalDialogForm.Quotes);

                else if (modalDialogForm.Type == ObserverType.CheatingDetector)
                    observer = new CheatingDetector(modalDialogForm.To, modalDialogForm.Header, modalDialogForm.Footer, modalDialogForm.Quotes);

                else
                    observer = new BigScreenObserver(new BigScreenForm());

                observer.Title = modalDialogForm.ObserverTitle;
                manager.AddObserver(observer);

                selectedObserver = null;
                observerView.SelectedIndices.Clear();
                refreshObserverView();
                refreshRacerLists();
            }
        }
        public void TestNotCheatersLocation()
        {
            CheatingDetector detector = new CheatingDetector("Test");

            Racer.Racer prevRacer = new Racer.Racer("Test", "Test", 1, 1);
            prevRacer.Location = 10;
            prevRacer.LastSeen = DateTime.Now;

            Racer.Racer prevRacer2 = new Racer.Racer("Test", "Test", 1, 2);
            prevRacer2.Location = 10;
            prevRacer2.LastSeen = DateTime.Now;

            Racer.Racer r = new Racer.Racer("Test", "Test", 1, 1);
            Racer.Racer r2 = new Racer.Racer("Test", "Test", 1, 2);

            r.Location = 15;
            r2.Location = 16;
            r.LastSeen = prevRacer.LastSeen + TimeSpan.FromSeconds(2);
            r2.LastSeen = prevRacer.LastSeen + TimeSpan.FromSeconds(3);

            Assert.That(detector.AreCheating(r, r2, prevRacer, prevRacer2), Is.False);
        }