private void AssertSerializesAsExpected <T>(EntityFilter filterToBeSerialized, string expectedSerialization) { GetReportContext <T> context = GetReportContext <T>(filterToBeSerialized); AsyncUtil.RunSync(() => this.pipelineElement.ProcessAsync(context, NullLogger.Instance, default)); TestHelper.AssertJsonEqual(expectedSerialization, context.SerializedRequest); }
/// <summary> /// Asynchronously Retrieve Project Report, with support for cancellation. /// </summary> /// <remarks> /// Retrieves a project report with filters to narrow down the results. /// </remarks> /// <param name="filter"> /// An instance of the <see cref="ProjectReportFilter"/> class, for narrowing down the results. /// </param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns> /// An instance of the <see cref="ProjectReport"/> class, along with /// an output instance of the <see cref="ResultsMeta"/> class containing additional data. /// </returns> public async Task <(ProjectReport, ResultsMeta)> GetProjectReportAsync( ProjectReportFilter filter, CancellationToken cancellationToken) { var context = new GetReportContext <ProjectReport>(EndpointName.ProjectReports, filter); await ExecuteOperationAsync(context, cancellationToken).ConfigureAwait(false); return(context.Results, context.ResultsMeta); }
public async Task GetReportDeserializer_CorrectlyDeserializesReportAsync() { var expectedItem0 = new TestReportItem(1234, "Bob", 86.25f); var expectedItem1 = new TestReportItem(1237, "Mary", 90.5f); GetReportContext <TestReport> context = GetReportContext <TestReport>(); await this.pipelineElement.ProcessAsync(context, NullLogger.Instance, default).ConfigureAwait(false); const int expectedCount = 2; Assert.AreEqual(expectedCount, context.Results.Report.Count, $"Expected {expectedCount} items in the report."); Assert.AreEqual(context.Results.Report[0], expectedItem0); Assert.AreEqual(context.Results.Report[1], expectedItem1); }
public void PipelineFactory_GivenGetReportContext_BuildsExpectedPipeline() { var context = new GetReportContext <TestEntity>( EndpointName.CurrentTotalsReports, null); var pipeline = (RequestPipeline)this.pipelineFactory.GetPipeline(context); Type[] expectedElementTypes = { typeof(GetReportSerializer), typeof(RestClientPostHandler), typeof(GetReportDeserializer), typeof(SupplementalDataDeserializer) }; IPipelineElement[] actualElements = pipeline.PipelineElements.ToArray(); AssertElements(expectedElementTypes, actualElements); }