Skip to content

Commit

Permalink
Failing test demonstrating #11448
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Johnson committed Nov 23, 2021
1 parent 8b06fa5 commit 7f1563d
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,5 +416,69 @@ public async Task GetUrlsByIds_DocumentWithUdiIds_ReturnsValidMap()
Assert.IsTrue(results![payload.ids[1]].StartsWith("/baz"));
});
}


[Test]
public async Task GetByIds_MultipleCalls_WorksAsExpected()
{
IContentTypeService contentTypeService = Services.GetRequiredService<IContentTypeService>();
IContentService contentService = Services.GetRequiredService<IContentService>();

var contentItems = new List<IContent>();

using (ScopeProvider.CreateScope(autoComplete: true))
{
IContentType contentType = ContentTypeBuilder.CreateBasicContentType();
contentTypeService.Save(contentType);

ContentBuilder builder = new ContentBuilder()
.WithContentType(contentType);

Content root = builder.WithName("foo").Build();
contentService.SaveAndPublish(root);

contentItems.Add(builder.WithParent(root).WithName("bar").Build());
contentItems.Add(builder.WithParent(root).WithName("baz").Build());

foreach (IContent content in contentItems)
{
contentService.SaveAndPublish(content);
}
}

var queryParameters = new Dictionary<string, object>
{
["type"] = Constants.UdiEntityType.Document
};

var url = LinkGenerator.GetUmbracoControllerUrl("GetByIds", typeof(EntityController), queryParameters);

var udiPayload = new
{
ids = new[]
{
contentItems[0].GetUdi().ToString(),
contentItems[1].GetUdi().ToString(),
}
};

var intPayload = new
{
ids = new[]
{
contentItems[0].Id,
contentItems[1].Id,
}
};

HttpResponseMessage udiResponse = await HttpClientJsonExtensions.PostAsJsonAsync(Client, url, udiPayload);
HttpResponseMessage intResponse = await HttpClientJsonExtensions.PostAsJsonAsync(Client, url, intPayload);

Assert.Multiple(() =>
{
Assert.AreEqual(HttpStatusCode.OK, udiResponse.StatusCode, "First request error");
Assert.AreEqual(HttpStatusCode.OK, intResponse.StatusCode, "Second request error");
});
}
}
}

0 comments on commit 7f1563d

Please sign in to comment.