public async Task Then_If_There_Is_A_CreateDemand_Id_Then_It_Is_Passed_To_The_Query( int trainingCourseId, Guid createDemandId, GetCreateCourseDemandQueryResult mediatorResult, [Frozen] Mock <IMediator> mediator, [Greedy] RegisterDemandController controller) { //Arrange mediator.Setup(x => x.Send(It.Is <GetCreateCourseDemandQuery>(c => c.TrainingCourseId.Equals(trainingCourseId) && c.CreateDemandId.Equals(createDemandId)) , It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); //Act var actual = await controller.RegisterDemand(trainingCourseId, createDemandId) as ViewResult; //Assert Assert.IsNotNull(actual); var actualModel = actual.Model as RegisterCourseDemandViewModel; Assert.IsNotNull(actualModel); actualModel.TrainingCourse.Should().BeEquivalentTo(mediatorResult.CourseDemand.Course); }
public async Task Then_If_There_Is_A_Validation_Exception_The_Register_View_Is_Returned( RegisterDemandRequest request, CreateCachedCourseDemandCommandResult mediatorResult, GetCreateCourseDemandQueryResult result, [Frozen] Mock <IMediator> mediator, [Greedy] RegisterDemandController controller) { //Arrange mediator.Setup(x => x.Send(It.IsAny <CreateCachedCourseDemandCommand>() , It.IsAny <CancellationToken>())) .ThrowsAsync(new ValidationException()); mediator.Setup(x => x.Send(It.Is <GetCreateCourseDemandQuery>(c => c.TrainingCourseId.Equals(request.TrainingCourseId)) , It.IsAny <CancellationToken>())) .ReturnsAsync(result); //Act var actual = await controller.PostRegisterDemand(request) as ViewResult; //Assert Assert.IsNotNull(actual); actual.ViewName.Should().Be("RegisterDemand"); }