コード例 #1
0
        public void CreateNewAccountTest(string username, string firstName, string lastName, string email, string affiliationAbbreviation)
        {
            TestDatabase        testDatabase        = new TestDatabase();
            TestDialogService   testDialogService   = new TestDialogService();
            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(testDatabase, testDialogService);

            User user = new User();

            user.Username  = username;
            user.FirstName = firstName;
            user.LastName  = lastName;
            user.Email     = email;

            /** Make an affiliation with matching abbreviation and store in DB **/
            Affiliation matchingAffiliation = new Affiliation();

            matchingAffiliation.Abbreviation = affiliationAbbreviation;
            user.Affiliation = matchingAffiliation;

            mainWindowViewModel.CreateAccount.User = user;
            mainWindowViewModel.CreateAccount.CreateNewAccount.Execute(null);

            user = mainWindowViewModel.CurrentUser;

            Assert.AreEqual(user.Username, username);
            Assert.AreEqual(user.FirstName, firstName);
            Assert.AreEqual(user.LastName, lastName);
            Assert.AreEqual(user.Email, email);
            Assert.AreEqual(user.Affiliation.Abbreviation, affiliationAbbreviation);
        }
コード例 #2
0
        public async Task GrabUserDetailsAsyncTest(string username, string firstName, string lastName, string email, string affiliationAbbreviation)
        {
            TestDatabase      testDatabase      = new TestDatabase();
            TestDialogService testDialogService = new TestDialogService();

            User user = new User();

            user.Username  = username;
            user.FirstName = firstName;
            user.LastName  = lastName;
            user.Email     = email;

            /** Make an affiliation with matching abbreviation and store in DB **/
            Affiliation matchingAffiliation = new Affiliation();

            matchingAffiliation.Abbreviation = affiliationAbbreviation;
            await testDatabase.AddNewAffiliationAsync(matchingAffiliation);

            user.Affiliation = matchingAffiliation;

            user = await testDatabase.AddNewUserAsync(user);

            Assert.AreEqual(user.Username, username);
            Assert.AreEqual(user.FirstName, firstName);
            Assert.AreEqual(user.LastName, lastName);
            Assert.AreEqual(user.Email, email);
            Assert.AreEqual(user.Affiliation.Abbreviation, affiliationAbbreviation);
        }
コード例 #3
0
        public async Task SaveNewMeetAsync(string name, string description, string startDateTime, string endDate)
        {
            /** 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);

            /** Make a temporary user **/
            var user = new User();

            user.FirstName   = "Database";
            user.LastName    = "Tester";
            user.Username    = "******";
            user.Email       = "*****@*****.**";
            user.Affiliation = mainWindowVM.CreateAffiliation.Affiliation;

            user = await testDB.AddNewUserAsync(user);

            mainWindowVM.CurrentUser = user;

            mainWindowVM.Registration.AddAddMeetView.Execute(null);
            var addMeetVM = (AddMeetViewModel)mainWindowVM.Registration.SelectedChildViewModel;

            addMeetVM.Meet.Name          = name;
            addMeetVM.Meet.Description   = description;
            addMeetVM.Meet.StartDateTime = Convert.ToDateTime(startDateTime);
            addMeetVM.Meet.EndDate       = Convert.ToDateTime(endDate);

            addMeetVM.StartDateTimeString = addMeetVM.Meet.StartDateTime.ToString();
            addMeetVM.SaveNewMeet.Execute(null);

            /** Get the meet(s) **/
            var meetsIEnum = await testDB.RefreshMeetsAsync(user);

            ObservableCollection <Meet> meets = new ObservableCollection <Meet>(meetsIEnum);

            var theMeet = meets.Last();

            /** Test Equality **/
            Assert.AreEqual(theMeet.Name, name);
            Assert.AreEqual(theMeet.Description, description);
            Assert.AreEqual(theMeet.StartDateTime, Convert.ToDateTime(startDateTime));
            Assert.AreEqual(theMeet.EndDate, Convert.ToDateTime(endDate));
            Assert.AreEqual(theMeet.Id, meets.Count());
            Assert.AreEqual(theMeet.UserId, user.Id);
        }
コード例 #4
0
        public async System.Threading.Tasks.Task SwitchToPreviousViewTestAsync()
        {
            TestDatabase      testDatabase      = new TestDatabase();
            TestDialogService testDialogService = new TestDialogService();

            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(testDatabase, testDialogService);

            mainWindowViewModel.ChildViewModel = mainWindowViewModel.Login;
            mainWindowViewModel.Login.AboutCommand.Execute(null);

            ChildView childView = mainWindowViewModel.ChildViewModel;

            childView.GoBackCommand.Execute(null);


            Assert.AreEqual(mainWindowViewModel.Login.GetType(), mainWindowViewModel.ChildViewModel.GetType());
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public async Task CheckLoginTest()
        {
            TestDatabase      testDatabase      = new TestDatabase();
            TestDialogService testDialogService = new TestDialogService();

            User user = new User();

            user.Username = "******";
            await testDatabase.AddNewUserAsync(user);

            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(testDatabase, testDialogService);

            mainWindowViewModel.Login.Username = "******";

            mainWindowViewModel.Login.LoginCommand.Execute(null);

            user = mainWindowViewModel.CurrentUser;
            Assert.AreEqual(user.Username, "username");
        }
コード例 #7
0
        public async Task SwitchViewLoginToRegistrationTestAsync()
        {
            TestDatabase      testDatabase      = new TestDatabase();
            TestDialogService testDialogService = new TestDialogService();

            User user = new User();

            user.Username = "******";
            await testDatabase.AddNewUserAsync(user);

            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(testDatabase, testDialogService);

            mainWindowViewModel.Login.Username = "******";

            mainWindowViewModel.Login.LoginCommand.Execute(null);

            var cvm = mainWindowViewModel.ChildViewModel;

            Assert.AreEqual(mainWindowViewModel.Registration, cvm);
        }