public void CheckContextualValidationRules() { Func<DeleteCourse.Request, ValidationMessageCollection> CallSut = request => { var serviceUnderTest = new DeleteCourseHandlerFactory().Object; var reponse = serviceUnderTest.Handle(request); return reponse.ValidationDetails; }; Assert2.CheckContextualValidation("CourseId", "CourseId must have a minimum value of 1", () => CallSut(CreateValidRequest(p => p.CommandModel.CourseId = 0))); }
public void WhenDeleteCourseIsCalledThenIExpectItToDoSomething() { // Arrange var repository = new InMemoryRecordedRepository(); var factory = new DeleteCourseHandlerFactory(); factory._SetRepository(repository); // Act var request = CreateValidRequest(); var response = factory.Object.Handle(request); // Assert response.HasValidationIssues.ShouldEqual(false); var events = repository.CommandRepository.CommandEvents; var course = (Course)events.DeletedEvents.First().Entity; course.CourseID.ShouldEqual(request.CommandModel.CourseId); events.SavedEvents.Count.ShouldEqual(1); events.ModifiedEvents.Count.ShouldEqual(0); events.DeletedEvents.Count.ShouldEqual(1); events.AddedEvents.Count.ShouldEqual(0); }