public void ValidatorReturnsFalseForInvalidToDateFormat() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); request.ToDate = "01-01-2020"; _listETRAMeetingsRequestValidator.ShouldHaveValidationErrorFor(r => r.ToDate, request.ToDate); }
public void CanGetListOfETRAMeetingsByDateRange() { ListETRAMeetingsRequest request = new ListETRAMeetingsRequest() { FromDate = "2019-04-01", ToDate = "2019-04-30" }; List <ETRAMeeting> response = new List <ETRAMeeting>() { new ETRAMeeting() { Name = "TEST ETRA meeting" } }; _eTRAMeetingsGateway.Setup(_ => _.GetETRAMeetingsByDateRange(request.FromDate, request.ToDate)).Returns(response); var results = _eTRAMeetingsUseCase.Execute(request); Assert.NotNull(results); Assert.True(results is ListETRAMeetingsResponse); Assert.True(results.ETRAMeetings.First() is ETRAMeeting); Assert.True(results.Request is ListETRAMeetingsRequest); Assert.Equal(response.FirstOrDefault().Name, results.ETRAMeetings.FirstOrDefault().Name); }
public void ValidatorReturnsFalseForEmptyToDate() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); request.ToDate = ""; _listETRAMeetingsRequestValidator.ShouldHaveValidationErrorFor(r => r.ToDate, request.ToDate); }
public void ValidatorReturnsFalseForMissingFromDate() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); request.FromDate = null; _listETRAMeetingsRequestValidator.ShouldHaveValidationErrorFor(r => r.FromDate, request.FromDate); }
public void ValidatorReturnsTrueForFromDateBeingBeforeToDate() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); var validationResult = _listETRAMeetingsRequestValidator.Validate(request); Assert.True(validationResult.IsValid); }
public void ValidatorReturnsFalseForFromDateBeingAfterToDate() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); request.FromDate = "2019-04-30"; request.ToDate = "2019-04-01"; var validationResult = _listETRAMeetingsRequestValidator.Validate(request); Assert.False(validationResult.IsValid); Assert.Equal("fromDate cannot be after toDate", validationResult.Errors[0].ErrorMessage); }
public void ExecuteReturnsResponseUsingsGatewayResults() { ListETRAMeetingsRequest request = new ListETRAMeetingsRequest() { FromDate = "2019-04-01", ToDate = "2019-04-30" }; List <ETRAMeeting> response = new List <ETRAMeeting>() { new ETRAMeeting() { Name = "TEST ETRA meeting" } }; _eTRAMeetingsGateway.Setup(_ => _.GetETRAMeetingsByDateRange(request.FromDate, request.ToDate)).Returns(response); var gwResponse = _eTRAMeetingsUseCase.Execute(request); _eTRAMeetingsGateway.Verify(gw => gw.GetETRAMeetingsByDateRange(request.FromDate, request.ToDate)); }
public IActionResult GetETRAMeetingsByDateRange([FromQuery] ListETRAMeetingsRequest request) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState.Values.SelectMany(x => x?.Errors?.Select(y => y?.ErrorMessage)))); } var meetings = _listETRAMeetings.Execute(request); return(Ok(meetings)); } catch (Exception ex) when(ex is MaTReportingApiBaseException) { return(StatusCode(StatusCodes.Status500InternalServerError, $"{ex.GetType().Name.ToString()} : {ex.Message}")); } catch { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ListETRAMeetingsResponse Execute(ListETRAMeetingsRequest request) { var result = _eTRAMeetingsGateway.GetETRAMeetingsByDateRange(request.FromDate, request.ToDate); return(new ListETRAMeetingsResponse(result, request, DateTime.Now, result.Count, result.Sum(x => x.NoOfActions))); }
public void ValidatorReturnsTrueForValidToDateFormat() { ListETRAMeetingsRequest request = GetValidListETRAMeetingsRequest(); _listETRAMeetingsRequestValidator.ShouldNotHaveValidationErrorFor(r => r.ToDate, request.ToDate); }