You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NuGetGallery/tests/CatalogTests/TestCatalogItem.cs

45 lines
1.1 KiB
C#

using Newtonsoft.Json.Linq;
using NuGet.Services.Metadata.Catalog;
using NuGet.Services.Metadata.Catalog.Persistence;
using System;
namespace CatalogTests
{
class TestCatalogItem : CatalogItem
{
string _name;
Uri _type;
public TestCatalogItem(string name)
{
_name = name;
_type = new Uri("http://test.org/schema#TestItem");
}
public override StorageContent CreateContent(CatalogContext context)
{
string id = BaseAddress + _name + ".json";
JObject obj = new JObject
{
{ "name", _name },
{ "@id", id },
{ "@type", _type },
{ "@context", new JObject { { "@vocab", "http://test.org/schema#" } } }
};
return new StringStorageContent(obj.ToString(), "application/json");
}
public override Uri GetItemType()
{
return _type;
}
public override Uri GetItemAddress()
{
return new Uri(BaseAddress, _name);
}
}
}