public void AddTeacher_WithValidTeacherAndCourse() { // Arrange: var model = new AddTeacherViewModel { SSN = SSN_GUNNA, Type = TeacherType.MainTeacher }; var prevCount = _teacherRegistrations.Count; // Act: var dto = _service.AddTeacherToCourse(COURSEID_VEFT_20163, model); // Assert: // Check that the dto object is correctly populated: Assert.AreEqual(SSN_GUNNA, dto.SSN); Assert.AreEqual(NAME_GUNNA, dto.Name); // Ensure that a new entity object has been created: var currentCount = _teacherRegistrations.Count; Assert.AreEqual(prevCount + 1, currentCount); // Get access to the entity object and assert that // the properties have been set: var newEntity = _teacherRegistrations.Last(); Assert.AreEqual(COURSEID_VEFT_20163, newEntity.CourseInstanceID); Assert.AreEqual(SSN_GUNNA, newEntity.SSN); Assert.AreEqual(TeacherType.MainTeacher, newEntity.Type); _mockUnitOfWork.Save(); // Ensure that the Unit Of Work object has been instructed // to save the new entity object: Assert.IsTrue(_mockUnitOfWork.GetSaveCallCount() > 0); }