public async Task Should_add_referenced_id_as_dependency() { var ref1_1 = CreateRefContent(Guid.NewGuid(), "ref1_1", 13); var ref1_2 = CreateRefContent(Guid.NewGuid(), "ref1_2", 17); var ref2_1 = CreateRefContent(Guid.NewGuid(), "ref2_1", 23); var ref2_2 = CreateRefContent(Guid.NewGuid(), "ref2_2", 29); var source = new IContentEntity[] { CreateContent(new Guid[] { ref1_1.Id }, new Guid[] { ref2_1.Id }), CreateContent(new Guid[] { ref1_2.Id }, new Guid[] { ref2_2.Id }) }; A.CallTo(() => contentQuery.QueryAsync(A <Context> .Ignored, A <IReadOnlyList <Guid> > .That.Matches(x => x.Count == 4))) .Returns(ResultList.CreateFrom(4, ref1_1, ref1_2, ref2_1, ref2_2)); var enriched = await sut.EnrichAsync(source, requestContext); var enriched1 = enriched.ElementAt(0); var enriched2 = enriched.ElementAt(1); Assert.Contains(refSchemaId1.Id.ToString(), enriched1.CacheDependencies); Assert.Contains(refSchemaId2.Id.ToString(), enriched1.CacheDependencies); Assert.Contains(refSchemaId1.Id.ToString(), enriched2.CacheDependencies); Assert.Contains(refSchemaId2.Id.ToString(), enriched2.CacheDependencies); }
public async Task Should_enrich_content_with_status_color() { var source = new ContentEntity { Status = Status.Published, SchemaId = schemaId }; A.CallTo(() => workflow.GetInfoAsync(Status.Published)) .Returns(new StatusInfo(Status.Published, StatusColors.Published)); var result = await sut.EnrichAsync(source); Assert.Equal(StatusColors.Published, result.StatusColor); }
public async Task Should_enrich_with_reference_data() { var ref1_1 = CreateRefContent(Guid.NewGuid(), "ref1_1", 13); var ref1_2 = CreateRefContent(Guid.NewGuid(), "ref1_2", 17); var ref2_1 = CreateRefContent(Guid.NewGuid(), "ref2_1", 23); var ref2_2 = CreateRefContent(Guid.NewGuid(), "ref2_2", 29); var source = new IContentEntity[] { CreateContent(new Guid[] { ref1_1.Id }, new Guid[] { ref2_1.Id }), CreateContent(new Guid[] { ref1_2.Id }, new Guid[] { ref2_2.Id }) }; A.CallTo(() => contentQuery.QueryAsync(A <Context> .Ignored, A <IReadOnlyList <Guid> > .That.Matches(x => x.Count == 4))) .Returns(ResultList.CreateFrom(4, ref1_1, ref1_2, ref2_1, ref2_2)); var enriched = await sut.EnrichAsync(source, requestContext); Assert.Equal( new NamedContentData() .AddField("ref1", new ContentFieldData() .AddJsonValue("iv", JsonValue.Object() .Add("en", "ref1_1, 13") .Add("de", "ref1_1, 13"))) .AddField("ref2", new ContentFieldData() .AddJsonValue("iv", JsonValue.Object() .Add("en", "ref2_1, 23") .Add("de", "ref2_1, 23"))), enriched.ElementAt(0).ReferenceData); Assert.Equal( new NamedContentData() .AddField("ref1", new ContentFieldData() .AddJsonValue("iv", JsonValue.Object() .Add("en", "ref1_2, 17") .Add("de", "ref1_2, 17"))) .AddField("ref2", new ContentFieldData() .AddJsonValue("iv", JsonValue.Object() .Add("en", "ref2_2, 29") .Add("de", "ref2_2, 29"))), enriched.ElementAt(1).ReferenceData); }
public async Task Should_add_app_version_and_schema_as_dependency() { var source = new ContentEntity { Status = Status.Published, SchemaId = schemaId }; A.CallTo(() => contentWorkflow.GetInfoAsync(source)) .Returns(new StatusInfo(Status.Published, StatusColors.Published)); var result = await sut.EnrichAsync(source, requestContext); Assert.Contains(requestContext.App.Version.ToString(), result.CacheDependencies); Assert.Contains(schema.Id.ToString(), result.CacheDependencies); Assert.Contains(schema.Version.ToString(), result.CacheDependencies); }