public void FinishedUpdate_ToString()
        {
            FinishedUpdate fUpdate = new FinishedUpdate
            {
                BibNumber       = 84,
                Timestamp       = new DateTime(2017, 8, 15, 14, 34, 0),
                OfficialEndTime = new DateTime(2017, 8, 15, 14, 33, 45)
            };

            Assert.AreEqual("Finished,84,8/15/2017 2:34:00 PM,8/15/2017 2:33:45 PM", fUpdate.ToString());
        }
示例#2
0
        public void RunTests()
        {
            GUIHandler handler = new GUIHandler();

            handler.AddAthlete(new Athlete(4));

            var finished = new FinishedUpdate();

            handler.updateObservers(finished);
            Athlete temp = (Athlete)handler.subjects[0];

            Assert.AreEqual(temp.observers.Count, 1);
        }
        public void FinishedUpdate_GetterAndSetters()
        {
            FinishedUpdate fUpdate = new FinishedUpdate
            {
                BibNumber       = 84,
                Timestamp       = new DateTime(2017, 8, 15, 14, 34, 0),
                OfficialEndTime = new DateTime(2017, 8, 15, 14, 33, 45)
            };

            Assert.AreEqual(AthleteRaceStatus.Finished, fUpdate.UpdateType);
            Assert.AreEqual(84, fUpdate.BibNumber);
            Assert.AreEqual(new DateTime(2017, 8, 15, 14, 34, 0), fUpdate.Timestamp);
            Assert.AreEqual(new DateTime(2017, 8, 15, 14, 33, 45), fUpdate.OfficialEndTime);
        }
示例#4
0
        /// <summary>
        /// Update the values provided in updateMessage
        /// </summary>
        /// <param name="updateMessage">Contains updated values</param>
        public void updateStats(AthleteUpdate updateMessage)
        {
            status    = updateMessage.UpdateType;
            timestamp = updateMessage.Timestamp;
            switch (updateMessage.UpdateType)
            {
            case AthleteRaceStatus.Registered:
                // Do nothing
                break;

            case AthleteRaceStatus.DidNotStart:
                // Do nothing
                break;

            case AthleteRaceStatus.Started:
                StartedUpdate startUpdate = (StartedUpdate)updateMessage;
                officialStartTime = startUpdate.OfficialStartTime;
                break;

            case AthleteRaceStatus.OnCourse:
                LocationUpdate locUpdate = (LocationUpdate)updateMessage;
                locationOnCourse = locUpdate.LocationOnCourse;
                break;

            case AthleteRaceStatus.DidNotFinish:
                // Do nothing
                break;

            case AthleteRaceStatus.Finished:
                FinishedUpdate finishUpdate = (FinishedUpdate)updateMessage;
                officialEndTime = finishUpdate.OfficialEndTime;
                break;

            default:
                throw new ApplicationException("Invalid AthleteUpdate type");
            }
            notifyObservers();
        }