public void Save_AddNew_Active_LecturerNotInList_Success()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_lecturer);
            VM                = new MySessionsLecturerPageVM(_lecturer, dbConName);
            VM.FormContext    = FormContext.Create;
            VM.SubgridContext = SubgridContext.ActiveSessions;

            ObservableCollection <Lecturer> LecLst = new ObservableCollection <Lecturer>();

            LecLst.Add(VM.AvailableLecturers.Where(l => l.Id == 555).FirstOrDefault());
            Group    group     = VM.Groups.Where(g => g.Id == 1).FirstOrDefault();
            DateTime startDate = DateTime.Now.Date;
            DateTime endDate   = DateTime.Now.Date;
            DateTime createdOn = DateTime.Now.Date.AddDays(-3);

            VM.SelectedSession = new Session("Test Session", startDate, endDate, LecLst, group, null, createdOn, _lecturer.Id);

            //Act
            bool result = VM.Save();
            //Assert
            int expectedSessions  = 1;
            int expectedLecturers = 2;
            int expectedGroups    = 3;

            Assert.IsTrue(result, $"Save Returned False: Message: {VM.FeedbackMessage}");
            Assert.AreEqual(FormContext.Create, VM.FormContext, "FormContext in wrong initial mode");
            Assert.AreEqual(Role.Lecturer, VM.UserRole, "UserRole in wrong initial mode for lecturer");
            Assert.AreEqual(expectedSessions, VM.MySessions.Count, $"VM Sessions Count Wrong.");
            Assert.AreEqual(expectedLecturers, VM.AvailableLecturers.Count, "VM Lecturer Count Wrong");
            Assert.AreEqual(expectedGroups, VM.Groups.Count, "VM Groups Count Wrong");//one null and the test one(s)
        }
        public void Save_UpdateSelected_Success()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_lecturer);
            VM             = new MySessionsLecturerPageVM(_lecturer, dbConName);
            VM.FormContext = FormContext.Create;
            //Act - update session details
            //select a session
            VM.SelectedSession = VM.MySessions.Where(s => s.Id == 2).FirstOrDefault();
            //update it
            VM.SelectedSession.Name  = "UpdatedTo";
            VM.SelectedSession.Group = VM.Groups.Where(g => g.Id == 2).FirstOrDefault();
            VM.SelectedSession.Lecturers.Add(VM.AvailableLecturers.Where(l => l.Id == 555).FirstOrDefault());
            VM.SelectedSession.StartTime = new DateTime(2019, 12, 06);
            VM.SelectedSession.EndTime   = new DateTime(2019, 12, 06);
            bool result = VM.Save();
            //Assert
            int expectedSessions  = 1;
            int expectedLecturers = 2;
            int expectedGroups    = 3;

            Assert.IsTrue(result, $"Save Returned False: Message: {VM.FeedbackMessage}");
            Assert.AreEqual(FormContext.Update, VM.FormContext, "FormContext in wrong initial mode");
            Assert.AreEqual(Role.Lecturer, VM.UserRole, "UserRole in wrong initial mode for lecturer");
            Assert.AreEqual(expectedSessions, VM.MySessions.Count, $"VM Sessions Count Wrong {VM.MySessions.Count} : should be {expectedSessions}");
            Assert.AreEqual(expectedLecturers, VM.AvailableLecturers.Count, "VM Lecturer Count Wrong");
            Assert.AreEqual(expectedGroups, VM.Groups.Count, "VM Groups Count Wrong");//one null and the test one(s)
        }