public async Task UpdateParticipantAsyncTestAsync(string firstName, string lastName, string gender, string affiliationAbbreviation, string birthDate) { /** Make a new database **/ var testDB = new TestDatabase(); /** Make the participant **/ Participant newParticipant = new Participant(); newParticipant.FirstName = firstName; newParticipant.LastName = lastName; if (gender.Equals("m")) { newParticipant.Gender = Participant.GenderType.Male; } else if (gender.Equals("f")) { newParticipant.Gender = Participant.GenderType.Female; } else { newParticipant.Gender = Participant.GenderType.Other; } newParticipant.BirthDate = Convert.ToDateTime(birthDate); /** Make an affiliation with matching abbreviation and store in DB **/ Affiliation matchingAffiliation = new Affiliation(); matchingAffiliation.Abbreviation = affiliationAbbreviation; matchingAffiliation.Name = affiliationAbbreviation; matchingAffiliation = await testDB.AddNewAffiliationAsync(matchingAffiliation); newParticipant.Affiliation = matchingAffiliation; /** Store participant in database **/ Participant returnedParticipant = await testDB.SaveNewParticipant(newParticipant); var tempParticipant = new Participant(); tempParticipant.Id = returnedParticipant.Id; tempParticipant.Affiliation = returnedParticipant.Affiliation; tempParticipant.FirstName = returnedParticipant.FirstName; tempParticipant.LastName = returnedParticipant.LastName; tempParticipant.Gender = returnedParticipant.Gender; tempParticipant.BirthDate = returnedParticipant.BirthDate; tempParticipant.BirthDate = tempParticipant.BirthDate.AddDays(1); await testDB.UpdateParticipantAsync(tempParticipant); /** Verify participant excists **/ var listParticipants = await testDB.RefreshParticipants(); ObservableCollection <Participant> participants = new ObservableCollection <Participant>(listParticipants); /** Test Equality On Changed Item of Participant**/ Assert.AreEqual(participants[0].BirthDate, Convert.ToDateTime(birthDate).AddDays(1)); }
public async Task RefreshParticipantsTest(int numAffiliations, int numParticipants) { /** Make a new database **/ var testDB = new TestDatabase(numAffiliations, numParticipants, 0); var affiliationsList = await testDB.RefreshAffiliations(); ObservableCollection <Affiliation> affiliations = new ObservableCollection <Affiliation>(affiliationsList); var participantsList = await testDB.RefreshParticipants(); ObservableCollection <Participant> participants = new ObservableCollection <Participant>(participantsList); Assert.AreEqual(affiliations.Count, numAffiliations); Assert.AreEqual(participants.Count, numParticipants); }
public async Task SaveNewParticipantTest(string firstName, string lastName, string gender, string affiliationAbbreviation, string birthDate) { /** Make a new database **/ var testDB = new TestDatabase(); /** Make the participant **/ Participant newParticipant = new Participant(); newParticipant.FirstName = firstName; newParticipant.LastName = lastName; if (gender.Equals("m")) { newParticipant.Gender = Participant.GenderType.Male; } else if (gender.Equals("f")) { newParticipant.Gender = Participant.GenderType.Female; } else { newParticipant.Gender = Participant.GenderType.Other; } /** Make an affiliation with matching abbreviation and store in DB **/ Affiliation matchingAffiliation = new Affiliation(); matchingAffiliation.Abbreviation = affiliationAbbreviation; await testDB.AddNewAffiliationAsync(matchingAffiliation); /** Store participant in database **/ Participant returnedParticipant = await testDB.SaveNewParticipant(newParticipant); newParticipant.Id = returnedParticipant.Id; /** Forces a failed test **/ //Participant returnedParticipant1 = await testDB.SaveNewParticipant(new Participant()); /** Verify participant excists **/ var listParticipants = await testDB.RefreshParticipants(); ObservableCollection <Participant> participants = new ObservableCollection <Participant>(listParticipants); /** Test Equality **/ Assert.AreEqual(participants[0], newParticipant); }
public async Task SaveNewParticipantAsync(string firstName, string lastName, string gender, string birthdate) { /** Make a new database **/ var testDB = new TestDatabase(); var testDialogService = new TestDialogService(); var mainWindowVM = new MainWindowViewModel(testDB, testDialogService); mainWindowVM.CreateAffiliation.Affiliation.Name = "My Affiliation"; mainWindowVM.CreateAffiliation.Affiliation.Abbreviation = "MA"; mainWindowVM.CreateAffiliation.CreateNewAffiliation.Execute(null); mainWindowVM.CurrentUser.Affiliation = mainWindowVM.CreateAffiliation.Affiliation; mainWindowVM.Registration.AddParticipantView.Execute(null); var addParticipantVM = (AddParticipantViewModel)mainWindowVM.Registration.SelectedChildViewModel; addParticipantVM.Participant.FirstName = firstName; addParticipantVM.Participant.LastName = lastName; if (gender.Equals("Male")) { addParticipantVM.Participant.Gender = Participant.GenderType.Male; } else if (gender.Equals("Female")) { addParticipantVM.Participant.Gender = Participant.GenderType.Female; } else { addParticipantVM.Participant.Gender = Participant.GenderType.Other; } addParticipantVM.Participant.BirthDate = Convert.ToDateTime(birthdate); addParticipantVM.SaveNewParticipant.Execute(null); /** Verify participant excists **/ var listParticipants = await testDB.RefreshParticipants(); ObservableCollection <Participant> participants = new ObservableCollection <Participant>(listParticipants); /** Test Equality **/ Assert.AreEqual(participants[0], addParticipantVM.Participant); }