public async Task Then_The_Service_Is_Called_And_TrainingProgramme_Returned() { //Arrange var trainingProgramme = new TrainingProgramme { Name = _standard.Title, CourseCode = _standard.Id, EffectiveFrom = _standard.EffectiveFrom, EffectiveTo = _standard.EffectiveTo, ProgrammeType = int.TryParse(_standard.Id, out var result) ? ProgrammeType.Standard : ProgrammeType.Framework, FundingPeriods = _standard.FundingPeriods.Select(x => new TrainingProgrammeFundingPeriod { EffectiveFrom = x.EffectiveFrom, EffectiveTo = x.EffectiveTo, FundingCap = x.FundingCap }).ToList() }; var query = new GetTrainingProgrammeQuery { Id = TrainingProgrammeId }; //Act var actual = await _handler.Handle(query); //Assert actual.TrainingProgramme.ShouldBeEquivalentTo(trainingProgramme); } }
public async Task Then_If_An_Exception_Is_Thrown_Then_Null_Is_Returned( GetTrainingProgrammeQuery query, TrainingProgramme result, [Frozen] Mock <ITrainingProgrammeLookup> service, GetTrainingProgrammeQueryHandler handler) { service.Setup(x => x.GetTrainingProgramme(query.Id)).ThrowsAsync(new Exception("Course not found")); var actual = await handler.Handle(query, CancellationToken.None); actual.TrainingProgramme.Should().BeNull(); }
public async Task Then_Null_Is_Returned_From_The_Service_When_There_Is_No_Course( GetTrainingProgrammeQuery query, TrainingProgramme result, [Frozen] Mock <ITrainingProgrammeLookup> service, GetTrainingProgrammeQueryHandler handler) { service.Setup(x => x.GetTrainingProgramme(query.Id)).ReturnsAsync((TrainingProgramme)null); var actual = await handler.Handle(query, CancellationToken.None); actual.TrainingProgramme.Should().BeNull(); }
public async Task Then_The_Data_Is_Retrieved_From_The_Service( GetTrainingProgrammeQuery query, TrainingProgramme result, [Frozen] Mock <ITrainingProgrammeLookup> service, GetTrainingProgrammeQueryHandler handler) { service.Setup(x => x.GetTrainingProgramme(query.Id)).ReturnsAsync(result); var actual = await handler.Handle(query, CancellationToken.None); actual.TrainingProgramme.Should().BeEquivalentTo(result); }