예제 #1
0
        public void RemoveObserverTest()
        {
            RegistrationUpdate regUpdate = new RegistrationUpdate("Registered", "3", "10/13/2017 10:00:00 PM", "Matt", "Morris", "M", "24");
            Athlete            athlete1  = new Athlete(regUpdate.Status, regUpdate.BibNumber, regUpdate.Timestamp.ToString(), regUpdate.LastName, regUpdate.Gender, regUpdate.Age);

            ConsoleObserver           consoleobserver     = new ConsoleObserver();
            _1DLineObserver           onedobserver        = new _1DLineObserver();
            AthleteComparisonObserver athletecompobserver = new AthleteComparisonObserver();
            ListObserver listobserver = new ListObserver();

            athlete1.RegisterObserver(consoleobserver);
            athlete1.RegisterObserver(onedobserver);
            athlete1.RegisterObserver(athletecompobserver);
            athlete1.RegisterObserver(listobserver);

            // test to see if observers are successfully removed
            try
            {
                athlete1.RemoveObserver(consoleobserver);
                athlete1.RemoveObserver(onedobserver);
                athlete1.RemoveObserver(athletecompobserver);
                athlete1.RemoveObserver(listobserver);
            }
            catch
            {
                Assert.Fail();
            }
        }
        public Registrations_tests()
        {
            _registrationController = new RegistrationController(_IRegistrationRepoMock.Object);

            _registrationDto = new RegistrationDto()
            {
                Title         = "Test",
                Description   = "This is a test",
                DateTime      = DateTime.Now,
                DoctorComment = "test comment",
                EmployeeId    = 1,
                PatientId     = 3
            };

            _registrationCreate = new RegistrationCreate()
            {
                Title       = "Test",
                Description = "This is a test",
                DateTime    = DateTime.Now,
                EmployeeId  = 1,
                PatientId   = 3
            };

            _registrationUpdate = new RegistrationUpdate()
            {
                Title         = "Updated Test",
                Description   = "This is a test",
                DateTime      = DateTime.Now,
                DoctorComment = "test comment",
                EmployeeId    = 1,
                PatientId     = 3,
            };
        }
        public async Task <ActionResult> UpdateRegistration([FromRoute] int id, [FromBody] RegistrationUpdate request)
        {
            var registrationDto = request.ToDto();
            var updated         = await _context.Update(registrationDto, id);

            if (!updated)
            {
                return(NotFound());
            }

            return(Ok());
        }
예제 #4
0
        public void RegistrationUpdate_ToString()
        {
            RegistrationUpdate rUpdate = new RegistrationUpdate
            {
                BibNumber = 14,
                Timestamp = new DateTime(2017, 8, 15, 7, 2, 5),
                FirstName = "Jane",
                LastName  = "Jones",
                Gender    = "F",
                Age       = 16
            };

            Assert.AreEqual("Registered,14,8/15/2017 7:02:05 AM,Jane,Jones,F,16", rUpdate.ToString());
        }
예제 #5
0
        public void NULLRemoveObserverTest()
        {
            RegistrationUpdate regUpdate = new RegistrationUpdate("Registered", "3", "10/13/2017 10:00:00 PM", "Matt", "Morris", "M", "24");
            Athlete            athlete1  = new Athlete(regUpdate.Status, regUpdate.BibNumber, regUpdate.Timestamp.ToString(), regUpdate.LastName, regUpdate.Gender, regUpdate.Age);

            // try to remove an observer if there are none
            try
            {
                athlete1.RemoveObserver(new ConsoleObserver());
            }
            catch {
                Assert.Fail();
            }
        }
예제 #6
0
        public void NULLNotifyObserversTest()
        {
            RegistrationUpdate regUpdate = new RegistrationUpdate("Registered", "3", "10/13/2017 10:00:00 PM", "Matt", "Morris", "M", "24");
            Athlete            athlete1  = new Athlete(regUpdate.Status, regUpdate.BibNumber, regUpdate.Timestamp.ToString(), regUpdate.LastName, regUpdate.Gender, regUpdate.Age);

            //try to notify observers when there are none
            try
            {
                athlete1.NotifyObservers();
            }
            catch
            {
                Assert.Fail();
            }
        }
예제 #7
0
        public void RegistrationUpdate_GetterAndSetters()
        {
            RegistrationUpdate rUpdate = new RegistrationUpdate
            {
                BibNumber = 14,
                Timestamp = new DateTime(2017, 8, 15, 7, 2, 5),
                FirstName = "Jane",
                LastName  = "Jones",
                Gender    = "F",
                Age       = 16
            };

            Assert.AreEqual(AthleteRaceStatus.Registered, rUpdate.UpdateType);
            Assert.AreEqual(14, rUpdate.BibNumber);
            Assert.AreEqual(new DateTime(2017, 8, 15, 7, 2, 5), rUpdate.Timestamp);
            Assert.AreEqual("Jane", rUpdate.FirstName);
            Assert.AreEqual("Jones", rUpdate.LastName);
            Assert.AreEqual("F", rUpdate.Gender);
            Assert.AreEqual(16, rUpdate.Age);
        }
예제 #8
0
        private void CreateNewAthlete(AthleteUpdate updateMessage)
        {
            RegistrationUpdate regUpdate = (RegistrationUpdate)updateMessage;
            Athlete            ath       = new Athlete()
            {
                status            = updateMessage.UpdateType,
                timestamp         = updateMessage.Timestamp,
                bibNumber         = updateMessage.BibNumber,
                firstName         = regUpdate.FirstName,
                lastName          = regUpdate.LastName,
                gender            = regUpdate.Gender,
                age               = regUpdate.Age,
                locationOnCourse  = 0.0,
                officialStartTime = null,
                officialEndTime   = null
            };

            athletes.Add(ath);
            RefreshAthLists(new object(), new EventArgs());
        }
예제 #9
0
        public void TheAthleteConstructorTest()
        {
            Athlete ath = new Athlete()
            {
                bibNumber         = 2,
                firstName         = "Billy",
                lastName          = "Joel",
                gender            = "M",
                age               = 73,
                status            = AthleteRaceStatus.Started,
                timestamp         = null,
                officialStartTime = null,
                officialEndTime   = null,
                locationOnCourse  = 123.456
            };

            Assert.AreEqual(2, ath.bibNumber);
            Assert.AreEqual("Billy", ath.firstName);
            Assert.AreEqual("Joel", ath.lastName);
            Assert.AreEqual("M", ath.gender);
            Assert.AreEqual(73, ath.age);
            Assert.AreEqual(AthleteRaceStatus.Started, ath.status);
            Assert.AreEqual(null, ath.timestamp);
            Assert.AreEqual(null, ath.officialStartTime);
            Assert.AreEqual(null, ath.officialEndTime);
            Assert.AreEqual(123.456, ath.locationOnCourse);

            AthleteUpdate update = new RegistrationUpdate()
            {
                BibNumber  = 2,
                UpdateType = AthleteRaceStatus.Registered,
                Timestamp  = new DateTime(2000, 1, 1)
            };

            ath.updateStats(update);


            Assert.AreEqual(2, ath.bibNumber);
            Assert.AreEqual(AthleteRaceStatus.Registered, ath.status);
            Assert.AreEqual(new DateTime(2000, 1, 1), ath.timestamp);
        }
예제 #10
0
        public void RegistrationUpdate_Create()
        {
            RegistrationUpdate rUpdate = (RegistrationUpdate)AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM,Jane,Jones,F,16");

            Assert.IsNotNull(rUpdate);

            Assert.AreEqual(AthleteRaceStatus.Registered, rUpdate.UpdateType);
            Assert.AreEqual(14, rUpdate.BibNumber);
            Assert.AreEqual(new DateTime(2017, 8, 15, 7, 2, 5), rUpdate.Timestamp);
            Assert.AreEqual("Jane", rUpdate.FirstName);
            Assert.AreEqual("Jones", rUpdate.LastName);
            Assert.AreEqual("F", rUpdate.Gender);
            Assert.AreEqual(16, rUpdate.Age);

            try
            {
                var msg = AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM,Jane,Jones,F");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM,Jane,Jones");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM,Jane");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered,14");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }

            try
            {
                var msg = AthleteUpdate.Create("Registered,14,8/15/2017 7:02:05 AM,Jane,Jones,F,16,bad");
                Assert.Fail($"Exception expected when creating: msg={msg}");
            }
            catch { /* ignore */ }
        }
예제 #11
0
 public object AccountUpdate(RegistrationUpdate update)
 {
     return(Status(Accounts.Update(update.Token, update.NewValues)));
 }