public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            StudentAssignedOffering expectedState = new StudentAssignedOffering
            {
                ServiceOffering = new ServiceOffering
                {
                    Provider = new Provider { Name = "provider name" },
                    ServiceType = new ServiceType { Name = "service type name" },
                    Program = new Program { Name = "program name" }
                },
                CreateTime = new DateTime(2005, 4, 30),
                CreatingUser = new User { DisplayName = "fredBob" },
                LastModifyTime = new DateTime(2010, 5, 13),
                LastModifyingUser = new User { DisplayName = "jimGeorge" }
            };
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;
            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }
        public void GivenAStudentAssignedOffering_WhenAdd_ThenAddToContext()
        {
            var expected = new StudentAssignedOffering { Id = 1 };

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
 public ManageAssignedOfferingPermission(StudentAssignedOffering studentAssignedOffering)
 {
     if (studentAssignedOffering == null)
     {
         throw new ArgumentNullException("assignedOffering");
     }
     StudentAssignedOffering = studentAssignedOffering;
 }
        public void GivenAStudentAssignedOffering_WhenUpdated_ThenContextSetsModified()
        {
            var expected = new StudentAssignedOffering { Id = 1 };

            Target.Update(expected);

            MockContext.AssertWasCalled(m => m.SetModified(expected));
        }
 public void Remove(StudentAssignedOffering item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     throw new NotSupportedException(string.Format("{0} entities cannot be removed.  Only \"soft\" deletes are supported via IsActive.", item.GetType().Name));
 }
 private void Create(StudentAssignedOffering studentAssignedOffering, DateTime dateAttended, Subject subject, decimal duration, string notes, EducationSecurityPrincipal user)
 {
     var newAttendance = new ServiceAttendance();
     newAttendance.StudentAssignedOffering = studentAssignedOffering;
     newAttendance.DateAttended = dateAttended;
     newAttendance.Subject = subject;
     newAttendance.Duration = duration;
     newAttendance.Notes = notes;
     newAttendance.CreatingUser = user.Identity.User;
     ServiceAttendanceRepository.Add(newAttendance);
 }
        public void WhenICopyFromADomainEntity_ThenViewModelContainsState()
        {
            StudentAssignedOffering source = new StudentAssignedOffering { Id = 12, EndDate = new DateTime(2004, 4, 5), Notes = "swkldfjwoi", ServiceOfferingId = 3483, StartDate = new DateTime(2001, 6, 21) };
            Target.CopyFrom(source);

            Assert.AreEqual(source.Id, Target.Id);
            Assert.AreEqual(source.EndDate, Target.EndDate);
            Assert.AreEqual(source.Notes, Target.Notes);
            Assert.AreEqual(source.ServiceOfferingId, Target.ServiceOfferingId);
            Assert.AreEqual(source.StartDate, Target.StartDate);
        }
 private void CreateNewStudentAssignedOffering(Student student, ServiceUploadModel model, DateTime? startDate, DateTime? endDate, string notes, EducationSecurityPrincipal user)
 {
     var newOffering = new StudentAssignedOffering()
     {
         StudentId = student.Id,
         CreatingUser = user.Identity.User,
         ServiceOfferingId = model.ServiceOfferingId,
         StartDate = startDate,
         EndDate = endDate,
         Notes = notes,
         IsActive = true
     };
     StudentAssignedOfferingRepository.Add(newOffering);
 }
        public void WhenICopyToDomainEntity_ThenDomainEntityContainsState()
        {
            StudentAssignedOffering destination = new StudentAssignedOffering();
            Target.Id = 12;
            Target.EndDate = new DateTime(2004, 4, 5);
            Target.Notes = "swkldfjwoi";
            Target.ServiceOfferingId = 3483;
            Target.StartDate = new DateTime(2001, 6, 21);
            Target.CopyTo(destination);

            //Assert.AreEqual(Target.Id, destination.Id);
            Assert.AreEqual(Target.EndDate, destination.EndDate);
            Assert.AreEqual(Target.Notes, destination.Notes);
            Assert.AreEqual(Target.ServiceOfferingId, destination.ServiceOfferingId);
            Assert.AreEqual(Target.StartDate, destination.StartDate);
        }
        public void GivenModelNotModified_WhenCopyFrom_ThenModelStatelastModifyValuesNull()
        {
            StudentAssignedOffering expectedState = new StudentAssignedOffering
            {
                ServiceOffering = new ServiceOffering
                {
                    Provider = new Provider { Name = "provider name" },
                    ServiceType = new ServiceType { Name = "service type name" },
                    Program = new Program { Name = "program name" }
                },
                CreateTime = new DateTime(2005, 4, 30),
                CreatingUser = new User { DisplayName = "fredBob" }
            };
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel();

            target.CopyFrom(expectedState);

            Assert.IsNull(target.Audit.LastModifiedBy);
            Assert.IsFalse(target.Audit.LastModifyTime.HasValue);
        }
 private static void AssertModelState(StudentAssignedOffering expectedState, int expectedStudentId, StudentServiceOfferingScheduleModel actual)
 {
     Assert.AreEqual(expectedState.Id, actual.Id);
     Assert.AreEqual(expectedState.EndDate, actual.EndDate);
     Assert.AreEqual(expectedState.Notes, actual.Notes);
     Assert.AreEqual(expectedState.StartDate, actual.StartDate);
 }
        public void GivenValidStudentAssignedOffering_WhenCopyTo_ThenModelHasViewModelData()
        {
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel { Id = 1, StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), Notes = "blah" };
            StudentAssignedOffering actual = new StudentAssignedOffering();

            target.CopyTo(actual);

            Assert.AreEqual(target.StartDate, actual.StartDate);
            Assert.AreEqual(target.EndDate, actual.EndDate);
            Assert.AreEqual(target.Notes, actual.Notes);
        }
 public void Update(StudentAssignedOffering item)
 {
     Context.SetModified(item);
 }
        public void GivenValidStudentAssignedOffering_WhenCopyFrom_ThenViewModelHasName()
        {
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel();
            StudentAssignedOffering offering = new StudentAssignedOffering
            {
                ServiceOffering = new ServiceOffering
                {
                    Provider = new Provider { Name = "provider name" },
                    ServiceType = new ServiceType { Name = "service type name" },
                    Program = new Program { Name = "program name" }
                },
                CreatingUser = new User()
            };

            target.CopyFrom(offering);

            Assert.AreEqual(target.Name, offering.ServiceOffering.Name);
        }
        public void GivenValidStudentAssignedOffering_WhenCopyFrom_ThenViewModelHasModelData()
        {
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel();
            StudentAssignedOffering offering = new StudentAssignedOffering
            {
                Id = 1,
                StartDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(1),
                Notes = "blah",
                ServiceOffering = new ServiceOffering
                {
                    Provider = new Provider(),
                    ServiceType = new ServiceType(),
                    Program = new Program()
                },
                CreatingUser = new User()
            };

            target.CopyFrom(offering);

            Assert.AreEqual(target.Id, offering.Id);
            Assert.AreEqual(target.StartDate, offering.StartDate);
            Assert.AreEqual(target.EndDate, offering.EndDate);
            Assert.AreEqual(target.Notes, offering.Notes);
        }
 public void Create(EducationSecurityPrincipal user, ServiceOfferingScheduleModel viewModel)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     if (!ServiceOfferingRepository.Items.Any(s => s.Id == viewModel.ServiceOfferingId && s.IsActive))
     {
         throw new EntityNotFoundException("Selected Service Offering was not found.");
     }
     ServiceOffering offering = ServiceOfferingRepository.Items.Single(s => s.Id == viewModel.ServiceOfferingId && s.IsActive);
     IEnumerable<Student> students = StudentRepository.Items.Include(s => s.School).Where(s => viewModel.SelectedStudents.Contains(s.Id));
     IPermission permission = PermissionFactory.Current.Create("ScheduleOffering", students, offering);
     permission.GrantAccess(user);
     User userEntity = user.Identity.User;
     List<int> studentIds = viewModel.SelectedStudents.ToList();
     foreach (int studentId in studentIds)
     {
         var studentAssignedOffering = new StudentAssignedOffering
         {
             StudentId = studentId,
             CreatingUserId = userEntity.Id,
             IsActive = true
         };
         viewModel.CopyTo(studentAssignedOffering);
         StudentAssignedOfferingRepository.Add(studentAssignedOffering);
     }
     RepositoryContainer.Save();
 }
 private void EditScheduledOffering(StudentServiceOfferingScheduleModel viewModel, StudentAssignedOffering existing, EducationSecurityPrincipal user)
 {
     existing.LastModifyingUser = user.Identity.User;
     existing.LastModifyTime = DateTime.Now;
     viewModel.CopyTo(existing);
     StudentAssignedOfferingRepository.Update(existing);
 }
        public void GivenOnlyInactiveStudentAssignedOffering_WhenCheckStudentOfferings_ThenSucceed()
        {
            Data.StudentAssignedOfferings.Clear();
            StudentAssignedOffering offering = new StudentAssignedOffering{ ServiceOfferingId = 1, IsActive = false };
            Data.ServiceOfferings[0].StudentAssignedOfferings.Add(offering);
            Data.StudentAssignedOfferings.Add(offering);

            Target.CheckStudentAssignedOfferings(1);
        }
 private StudentAssignedOffering CreateNewStudentAssignedOffering(Student student, ServiceUploadModel model, EducationSecurityPrincipal user)
 {
     var newOffering = new StudentAssignedOffering();
     newOffering.Student = student;
     newOffering.StudentId = student.Id;
     newOffering.CreatingUser = user.Identity.User;
     newOffering.ServiceOfferingId = model.ServiceOfferingId;
     newOffering.StartDate = DateTime.Now;
     newOffering.CreateTime = DateTime.Now;
     newOffering.IsActive = true;
     StudentAssignedOfferingRepository.Add(newOffering);
     return newOffering;
 }
        public void WhenConstruct_ThenCreateTimeSet()
        {
            StudentAssignedOffering actual = new StudentAssignedOffering();

            Assert.IsTrue(actual.CreateTime.WithinTimeSpanOf(TimeSpan.FromMilliseconds(20), DateTime.Now));
        }
 private static void AssertAssignedOffering(StudentServiceOfferingScheduleModel expected, StudentAssignedOffering actual)
 {
     Assert.IsNotNull(actual);
     Assert.AreEqual(0, actual.Id); //Since we are adding the Id will always be 0
     Assert.AreEqual(expected.EndDate, actual.EndDate);
     Assert.AreEqual(expected.Notes, actual.Notes);
     Assert.AreEqual(expected.StartDate, actual.StartDate);
 }
 private static bool MatchProperties(ServiceAttendance actualState, StudentAssignedOffering expectedStudentAssignedOffering, DateTime expectedDateAttended, Subject expectedSubject, decimal expectedDuration, string expectedNotes)
 {
     Assert.AreEqual(expectedStudentAssignedOffering, actualState.StudentAssignedOffering);
     Assert.AreEqual(expectedDateAttended, actualState.DateAttended);
     Assert.AreEqual(expectedSubject.Id, actualState.Subject.Id);
     Assert.AreEqual(expectedDuration, actualState.Duration);
     Assert.AreEqual(expectedNotes, actualState.Notes);
     return true;
 }
Exemple #23
0
        public void WhenConstruct_ThenCreateTimeSet()
        {
            StudentAssignedOffering actual = new StudentAssignedOffering();

            Assert.IsTrue(actual.CreateTime.WithinTimeSpanOf(TimeSpan.FromMilliseconds(20), DateTime.Now));
        }
        public void GivenAnAssignedOffering_WhenRemove_ThenThrowNotSupportedException()
        {
            var item = new StudentAssignedOffering { Id = 1 };

            Target.ExpectException<NotSupportedException>(() => Target.Remove(item));
        }
 public void Add(StudentAssignedOffering item)
 {
     Context.StudentAssignedOfferings.Add(item);
 }