public void WhenCourseCreateIsCalledThenIExpectItToDoSomething() { // Arrange var repository = new InMemoryRecordedRepository(); // Act var request = CreateValidRequest(); var response = CourseHandlers.Handle(repository, request); // Assert response.HasValidationIssues.ShouldEqual(false); var events = repository.CommandRepository.CommandEvents; var course = (Course)events.AddedEvents.First().Entity; course.CourseID.ShouldEqual(request.CommandModel.CourseID); course.Credits.ShouldEqual(request.CommandModel.Credits); course.DepartmentID.ShouldEqual(request.CommandModel.DepartmentID); course.Title.ShouldEqual(request.CommandModel.Title); events.SavedEvents.Count.ShouldEqual(1); events.ModifiedEvents.Count.ShouldEqual(0); events.DeletedEvents.Count.ShouldEqual(0); events.AddedEvents.Count.ShouldEqual(1); }
public void WhenCourseUpdateCreditsIsCalledThenIExpectItToDoSomething() { var efTestExtensions = new EfRepositoryTestExtension(); EntityFrameworkRepositoryExtensions.SetDefaultImplementation(efTestExtensions); // Arrange var repository = new InMemoryRecordedRepository(); // Act var request = CreateValidRequest(); var response = CourseHandlers.Handle(repository, request); // Assert response.HasValidationIssues.ShouldEqual(false); efTestExtensions.ExecuteStoredProcudureCallCount.ShouldEqual(1); }
public static void SetUp() { // Create repository Func <IRepository> CreateRepository = () => new EntityFrameworkRepository(new ContosoDbContext(), new ContosoUniversityRepositoryInterceptors()); // Courses DomainServices.AddService <CourseCreate.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseDelete.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseUpdate.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseUpdateCredits.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); // Instructors DomainServices.AddService <InstructorDelete.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <InstructorModifyAndCourses.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <InstructorCreateWithCourses.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); // Students DomainServices.AddService <StudentDelete.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <StudentCreate.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <StudentModify.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); // Departments DomainServices.AddService <DepartmentDelete.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <DepartmentCreate.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <DepartmentUpdate.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); }