public void Club_AddSwimmers_Exception() { //Arrange Club newClub = new Club(); Registrant swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1), new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567); Registrant swimmer2 = new Registrant { Address = new Address("1 King St", "Toronto", "ON", "M2M 3M3"), Name = "John Lee", PhoneNumber = 4162222222, DateOfBirth = new DateTime(1950, 12, 1) }; Registrant swimmer3 = new Registrant("Ann Smith", new DateTime(1975, 1, 1), new Address("5 Queen St", "Toronto", "ON", "M2M 4M4"), 4163333333); newClub.AddSwimmer(swimmer1); newClub.AddSwimmer(swimmer2); newClub.AddSwimmer(swimmer3); try { newClub.AddSwimmer(swimmer3); } catch (Exception e) { StringAssert.Contains(e.Message, "Swimmer is registered with a different club " + swimmer3.Club.Name); } }
public void Test_Club_AddSwimmerMethod_NumRegistrantsProperty() { int expectedResult = 2; Club aClub = new Club("Club 1", new Address("7 Caley", "Toronto", "ON", "M1C 1E3"), 4164588700); Registrant aSwimmer = new Registrant("Rick Sanchez", new DateTime(1980, 10, 5), new Address("8 Caley", "Toronto", "ON", "M1E 1E3"), 4164588888); Registrant aNewSwimmer = new Registrant(); aClub.AddSwimmer(aSwimmer); aClub.AddSwimmer(aNewSwimmer); Assert.AreEqual(expectedResult, aClub.NumRegistrants); }
public void Registrant_ClubProperty_Exception() { Registrant swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1), new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567); Registrant swimmer2 = new Registrant { Address = new Address("1 King St", "Toronto", "ON", "M2M 3M3"), Name = "John Lee", PhoneNumber = 4162222222, DateOfBirth = new DateTime(1950, 12, 1) }; Club club1 = new Club { PhoneNumber = 4164444444, Name = "NYAC" }; Club club2 = new Club("CCAC", new Address("35 River St", "Toronto", "ON", "M2M 5M5"), 4165555555); club1.AddSwimmer(swimmer1); club2.AddSwimmer(swimmer2); try { swimmer2.Club = club1; } catch (Exception ex) { StringAssert.Contains(ex.Message, "Swimmer is registered with a different club " + swimmer2.Club.Name); // Assert.AreNotEqual(ex.Message, "Swimmer is registered with a different club "+ swimmer2.Club.Name); // return; } //Assert.Fail(); }
public void Registrant_AssigningClub_NoException() { Registrant swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1), new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567); Registrant swimmer2 = new Registrant { Address = new Address("1 King St", "Toronto", "ON", "M2M 3M3"), Name = "John Lee", PhoneNumber = 4162222222, DateOfBirth = new DateTime(1950, 12, 1) }; Registrant swimmer3 = new Registrant("Ann Smith", new DateTime(1975, 1, 1), new Address("5 Queen St", "Toronto", "ON", "M2M 4M4"), 4163333333); Club club1 = new Club { PhoneNumber = 4164444444, Name = "NYAC" }; Club club2 = new Club("CCAC", new Address("35 River St", "Toronto", "ON", "M2M 5M5"), 4165555555); club1.AddSwimmer(swimmer1); club2.AddSwimmer(swimmer2); try { swimmer3.Club = club1; } catch (Exception ex) { StringAssert.Contains(ex.Message, "Swimmer is registered with a different club " + swimmer3.Club.Name); } }
private static void AssigneSwimmersToClubs(Registrant swimmer1, Registrant swimmer2, Registrant swimmer3, Club club1, Club club2) { Console.WriteLine("*******Adding swimmers to clubs ******\n***********************************"); club1.AddSwimmer(swimmer1); DisplayInfo("club1", club1); DisplayInfo("swimmer1", swimmer1); club2.AddSwimmer(swimmer2); DisplayInfo("club2", club2); DisplayInfo("swimmer2", swimmer2); try { swimmer2.Club = club1; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { swimmer3.Club = club1; } catch (Exception ex) { Console.WriteLine(ex.Message); } DisplayInfo("swimmer3", swimmer3); DisplayInfo("club1", club1); }
public void Test_Club_AddSwimmerMethod_UserToMultipleClubs() { Club aClub = new Club("Club 1", new Address("7 Caley", "Toronto", "ON", "M1C 1E3"), 4164588700); Registrant aSwimmer = new Registrant("Rick Sanchez", new DateTime(1980, 10, 5), new Address("8 Caley", "Toronto", "ON", "M1E 1E3"), 4164588888); Club aClub2 = new Club(); aClub.AddSwimmer(aSwimmer); aClub2.AddSwimmer(aSwimmer); }
public void Club_AddSwimmerToClub_UpdateSwimmer() { Club club1 = new Club(); Registrant swimmer1 = new Registrant(); Assert.AreEqual(swimmer1.Club, null); club1.AddSwimmer(swimmer1); Assert.AreEqual(swimmer1.Club, club1); }
public void ClubAddSwimmer_AddingRegistrant_UpdatesGetInfo() { //setup Club club = new Club("Dummy Club", new Address(), 0, 100); Registrant registrant = new Registrant("Bob", new DateTime(), new Address(), 0, 200); club.AddSwimmer(registrant); StringAssert.Contains("Bob", club.ToString()); }
public void Test_Coach_AddSwimmerCoachIsNotAssignedException() { Coach aCoach = new Coach("Micael Phelps", new DateTime(1975, 6, 30), new Address("5 Queen St", "Boston", "ON", "M1L 6Y7"), 3123123333); Club aClub = new Club(); aClub.Name = "Cool new club2"; Swimmer aSwimmer = new Swimmer(); aClub.AddSwimmer(aSwimmer); aCoach.AddSwimmer(aSwimmer); }
public void Test_Swimmer_CoachProperty() { Coach aCoach = new Coach("Micael Phelps", new DateTime(1975, 6, 30), new Address("5 Queen St", "Boston", "ON", "M1L 6Y7"), 3123123333);//6 Club aClub = new Club(); aClub.Name = "another club"; aClub.AddCoach(aCoach); Club bClub = new Club(); Swimmer aSwimmer = new Swimmer(); bClub.AddSwimmer(aSwimmer); aSwimmer.Coach = aCoach; }
public void Test_Coach_AddSwimmerDifferentClubException() { Coach aCoach = new Coach("Micael Phelps", new DateTime(1975, 6, 30), new Address("5 Queen St", "Boston", "ON", "M1L 6Y7"), 3123123333);//6 Club aClub = new Club(); aClub.Name = "Cool new club3"; aClub.AddCoach(aCoach); Club bClub = new Club(); Swimmer aSwimmer = new Swimmer(); bClub.AddSwimmer(aSwimmer); aCoach.AddSwimmer(aSwimmer); }
public void Test_Coach_AddSwimmerMethods() { Coach aCoach = new Coach("Micael Phelps", new DateTime(1975, 6, 30), new Address("5 Queen St", "Boston", "ON", "M1L 6Y7"), 3123123333); Club aClub = new Club(); aClub.Name = "Cool new club"; aClub.AddCoach(aCoach); Swimmer aSwimmer = new Swimmer(); aSwimmer.Name = "Randalph"; aClub.AddSwimmer(aSwimmer); aCoach.AddSwimmer(aSwimmer); Assert.AreEqual(aSwimmer.Name, aCoach.Swimmers[0].Name); }
public void AddSwimmerMethodGivingExceptionWhenCoachIsNotRegisteredToAClub() { //arrange Club.count = 0; Swimmer aSwimmer = new Swimmer(); Club aClub = new Club(); Coach aCoach = new Coach("dave", new DateTime(), new Address(), 1234567890); //act // aClub.AddCoach(aCoach); aClub.AddSwimmer(aSwimmer); aCoach.AddSwimmer(aSwimmer); Swimmer expected = aSwimmer; //Assert }
public void Club_AddSwimmerToClub_ShouldThrowException() { Club club1 = new Club(); Club club2 = new Club(); Registrant swimmer1 = new Registrant(); club1.AddSwimmer(swimmer1); try { club2.AddSwimmer(swimmer1); } catch (Exception e) { StringAssert.Contains(e.Message, "Swimmer already assigned to club"); return; } }
public void AddSwimmerMethodWorkingProperly() { //arrange Club.count = 0; Swimmer aSwimmer = new Swimmer(); Club aClub = new Club(); Coach aCoach = new Coach("dave", new DateTime(), new Address(), 1234567890); //act aClub.AddCoach(aCoach); aClub.AddSwimmer(aSwimmer); aCoach.AddSwimmer(aSwimmer); Swimmer expected = aSwimmer; //Assert Swimmer actual = aCoach.listOfSwimmers[0]; Assert.AreEqual(expected, actual); }
public void ClubAddSwimmer_AddingRegistrantsTo2Clubs_ShouldThrowException() { //setup Club club = new Club("Dummy Club", new Address(), 0, 100); Registrant registrant1 = new Registrant("Bob", new DateTime(), new Address(), 0, 200); club.AddSwimmer(registrant1); Club club2 = new Club("The Other Dummy Club", new Address(), 0, 101); //act try { club2.AddSwimmer(registrant1); } catch (Exception ex) { StringAssert.Contains("Swimmer is registered with a different club", ex.Message); return; } Assert.Fail(); }
public void Club_AddSwimmer_Same() { //arrange Club newClub = new Club(); Registrant swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1), new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567); Registrant swimmer2 = new Registrant { Address = new Address("1 King St", "Toronto", "ON", "M2M 3M3"), Name = "John Lee", PhoneNumber = 4162222222, DateOfBirth = new DateTime(1950, 12, 1) }; Swimmer swimmer3 = new Swimmer("Ann Smith", new DateTime(1975, 1, 1), new Address("5 Queen St", "Toronto", "ON", "M2M 4M4"), 4163333333); //act newClub.AddSwimmer(swimmer1); string expectedSwimmerName = "Bob Smith"; //assert //Assert.AreEqual(expectedSwimmerName, newClub.Swimmers[0].Name, "Swimmer is not same"); }