Skip to content

Commit

Permalink
ASType: expose AS types and JSON-LD context (resolves #158)
Browse files Browse the repository at this point in the history
  • Loading branch information
warriordog committed Dec 26, 2023
1 parent 181c23f commit 2cba7e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Source/ActivityPub.Types/AS/ASType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
using ActivityPub.Types.Util;
using JetBrains.Annotations;
Expand Down Expand Up @@ -68,6 +67,12 @@ public ASType(TypeMap typeMap, ASTypeEntity? entity)
/// </summary>
public TypeMap TypeMap { get; }

/// <inheritdoc cref="TypeMap.ASTypes"/>
public IReadOnlySet<string> Type => TypeMap.ASTypes;

/// <inheritdoc cref="TypeMap.LDContext"/>
public IJsonLDContext JsonLDContext => TypeMap.LDContext;

/// <summary>
/// Provides the globally unique identifier for an <code>Object</code> or <code>Link</code>.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Test/ActivityPub.Types.Tests/Unit/AS/ASTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ public abstract class ASTypeTests
{
private ASType ObjectUnderTest { get; } = new StubASType();

public class JsonLdContextsShould : ASTypeTests
public class JsonLdContextShould : ASTypeTests
{
[Fact]
public void ContainASContext_ByDefault()
{
ObjectUnderTest.TypeMap.LDContext.Should().Contain("https://www.w3.org/ns/activitystreams");
ObjectUnderTest.JsonLDContext.Should().Contain("https://www.w3.org/ns/activitystreams");
}
}

public class TypesShould : ASTypeTests
public class TypeShould : ASTypeTests
{
[Fact]
public void ContainTypeName_ByDefault()
{
ObjectUnderTest.TypeMap.ASTypes.Should().Contain(StubASType.StubType);
ObjectUnderTest.Type.Should().Contain(StubASType.StubType);
}
}

Expand Down

0 comments on commit 2cba7e1

Please sign in to comment.