-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
types: fix crash when extending a type graph
This is a workaround-quality fix. A more robust solution would involve constructor changes in every model type. Base types would need to enter through the "wrap existing" constructor instead of the "extends" constructor.
- Loading branch information
1 parent
69443a5
commit f304216
Showing
2 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
// If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
using ActivityPub.Types.AS; | ||
using ActivityPub.Types.AS.Extended.Actor; | ||
using ActivityPub.Types.AS.Extended.Object; | ||
|
||
namespace ActivityPub.Types.Tests.Unit.AS; | ||
|
||
public abstract class APActorTests | ||
{ | ||
public class ExtendConstructorShould : APActorTests | ||
{ | ||
[Fact] | ||
public void ExtendRegularObject() | ||
{ | ||
var note = new NoteObject() | ||
{ | ||
Id = "https://example.com/object", | ||
Content = "content" | ||
}; | ||
|
||
var actor = new APActor(note) | ||
{ | ||
Inbox = "https://example.com/inbox", | ||
Outbox = "https://example.com/outbox" | ||
}; | ||
|
||
actor.Is<NoteObject>().Should().BeTrue(); | ||
note.Is<APActor>().Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void NoOpWhenWrappingAnotherActor() | ||
{ | ||
var person = new PersonActor() | ||
{ | ||
Inbox = "https://example.com/inbox", | ||
Outbox = "https://example.com/outbox" | ||
}; | ||
var actor = new APActor(person) | ||
{ | ||
Inbox = person.Inbox, | ||
Outbox = person.Outbox | ||
}; | ||
|
||
person.Inbox = "https://example.com/changed"; | ||
|
||
actor.Inbox.Should().Be(person.Inbox); | ||
} | ||
} | ||
} |