public void Get_WhenValidApplicationIsPassed_ExpectEntityHasProperId()
        {
            // Arrange
            const int id = 7;
            const int studentId = 11;

            var application =
                new ApplicationEntity
                    {
                        Id = id,
                        StudentId = studentId,
                    };
            var student = new StudentEntity { Id = studentId, };
            var individual = new IndividualEntity { Id = studentId, };

            var stubApplicationRepo = new Mock<IRepository<ApplicationEntity>>();
            stubApplicationRepo.Setup(e => e.Retrieve(id))
                .Returns(application);

            var stubStudentRepo = new Mock<IRepository<StudentEntity>>();
            stubStudentRepo.Setup(e => e.Retrieve(studentId))
                .Returns(student);

            var stubIndividualRepo = new Mock<IRepository<IndividualEntity>>();
            stubIndividualRepo.Setup(e => e.Retrieve(studentId))
                .Returns(individual);

            var classUnderTest = new Application(stubIndividualRepo.Object, stubStudentRepo.Object, stubApplicationRepo.Object);

            // Act
            classUnderTest.Get(id);

            // Assert
            var actual = classUnderTest.Id;
            Assert.AreEqual(id, actual);
        }
Example #2
0
        internal void LoadData(
            IndividualEntity individual, 
            StudentEntity student)
        {
            Id = student.Id;

            LastName = individual.LastName;
            FirstName = individual.FirstName;
            MiddleInitial = GetMiddleInitial(individual.MiddleName);
            Suffix = individual.Suffix;
            DateOfBirth = individual.DateOfBirth;

            this.HighSchool = 
                new School
                    {
                        Name = student.HighSchoolName, 
                        City = student.HighSchoolCity, 
                        State = student.HighSchoolState,
                    };
        }
        public void Save_WithAnExistingStudent_ExpectIndividualDalUpdateIsCalledOnce()
        {
            // Arrange
            var today = new DateTime(2003, 5, 17);

            const int ExpectedStudentId = 897931;
            var studentEntity = new StudentEntity { Id = ExpectedStudentId, };

            var stubStudentRepo = new Mock<IRepository<StudentEntity>>();
            stubStudentRepo
                .Setup(e => e.Retrieve(ExpectedStudentId))
                .Returns(studentEntity);

            var mockIndividualRepo = new Mock<IRepository<IndividualEntity>>();
            mockIndividualRepo
                .Setup(e => e.Update(It.IsAny<IndividualEntity>()));

            var classUnderTest =
                new Student(mockIndividualRepo.Object, stubStudentRepo.Object)
                {
                    Id = ExpectedStudentId,
                    Today = today,
                    DateOfBirth = today.AddYears(-19),
                };

            // Act
            classUnderTest.Save();

            // Assert
            Assert.AreEqual(ExpectedStudentId, classUnderTest.Id);
            mockIndividualRepo
                .Verify(e => e.Update(It.IsAny<IndividualEntity>()), Times.Once());
        }