|
|
@ -20,11 +20,11 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
{ |
|
|
{ |
|
|
public class AppDomainObjectTests : HandlerTestBase<AppDomainObject> |
|
|
public class AppDomainObjectTests : HandlerTestBase<AppDomainObject> |
|
|
{ |
|
|
{ |
|
|
private readonly AppDomainObject sut; |
|
|
|
|
|
private readonly string contributorId = Guid.NewGuid().ToString(); |
|
|
private readonly string contributorId = Guid.NewGuid().ToString(); |
|
|
private readonly string clientId = "client"; |
|
|
private readonly string clientId = "client"; |
|
|
private readonly string clientNewName = "My Client"; |
|
|
private readonly string clientNewName = "My Client"; |
|
|
private readonly string planId = "premium"; |
|
|
private readonly string planId = "premium"; |
|
|
|
|
|
private readonly AppDomainObject sut; |
|
|
|
|
|
|
|
|
public AppDomainObjectTests() |
|
|
public AppDomainObjectTests() |
|
|
{ |
|
|
{ |
|
|
@ -73,6 +73,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.ChangePlan(CreateCommand(new ChangePlan { PlanId = planId })); |
|
|
sut.ChangePlan(CreateCommand(new ChangePlan { PlanId = planId })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(planId, sut.State.Plan.PlanId); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppPlanChanged { PlanId = planId }) |
|
|
CreateEvent(new AppPlanChanged { PlanId = planId }) |
|
|
@ -95,6 +97,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.AssignContributor(CreateCommand(new AssignContributor { ContributorId = contributorId, Permission = AppContributorPermission.Editor })); |
|
|
sut.AssignContributor(CreateCommand(new AssignContributor { ContributorId = contributorId, Permission = AppContributorPermission.Editor })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(AppContributorPermission.Editor, sut.State.Contributors[contributorId]); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppContributorAssigned { ContributorId = contributorId, Permission = AppContributorPermission.Editor }) |
|
|
CreateEvent(new AppContributorAssigned { ContributorId = contributorId, Permission = AppContributorPermission.Editor }) |
|
|
@ -118,6 +122,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
sut.AssignContributor(CreateCommand(new AssignContributor { ContributorId = contributorId, Permission = AppContributorPermission.Editor })); |
|
|
sut.AssignContributor(CreateCommand(new AssignContributor { ContributorId = contributorId, Permission = AppContributorPermission.Editor })); |
|
|
sut.RemoveContributor(CreateCommand(new RemoveContributor { ContributorId = contributorId })); |
|
|
sut.RemoveContributor(CreateCommand(new RemoveContributor { ContributorId = contributorId })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.False(sut.State.Contributors.ContainsKey(contributorId)); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents().Skip(1) |
|
|
sut.GetUncomittedEvents().Skip(1) |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppContributorRemoved { ContributorId = contributorId }) |
|
|
CreateEvent(new AppContributorRemoved { ContributorId = contributorId }) |
|
|
@ -142,6 +148,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.AttachClient(CreateCommand(command)); |
|
|
sut.AttachClient(CreateCommand(command)); |
|
|
|
|
|
|
|
|
|
|
|
Assert.True(sut.State.Clients.ContainsKey(clientId)); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppClientAttached { Id = clientId, Secret = command.Secret }) |
|
|
CreateEvent(new AppClientAttached { Id = clientId, Secret = command.Secret }) |
|
|
@ -165,6 +173,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.RevokeClient(CreateCommand(new RevokeClient { Id = clientId })); |
|
|
sut.RevokeClient(CreateCommand(new RevokeClient { Id = clientId })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.False(sut.State.Clients.ContainsKey(clientId)); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppClientRevoked { Id = clientId }) |
|
|
CreateEvent(new AppClientRevoked { Id = clientId }) |
|
|
@ -188,6 +198,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.UpdateClient(CreateCommand(new UpdateClient { Id = clientId, Name = clientNewName, Permission = AppClientPermission.Developer })); |
|
|
sut.UpdateClient(CreateCommand(new UpdateClient { Id = clientId, Name = clientNewName, Permission = AppClientPermission.Developer })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(clientNewName, sut.State.Clients[clientId].Name); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppClientRenamed { Id = clientId, Name = clientNewName }), |
|
|
CreateEvent(new AppClientRenamed { Id = clientId, Name = clientNewName }), |
|
|
@ -211,6 +223,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.AddLanguage(CreateCommand(new AddLanguage { Language = Language.DE })); |
|
|
sut.AddLanguage(CreateCommand(new AddLanguage { Language = Language.DE })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.True(sut.State.LanguagesConfig.Contains(Language.DE)); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppLanguageAdded { Language = Language.DE }) |
|
|
CreateEvent(new AppLanguageAdded { Language = Language.DE }) |
|
|
@ -234,6 +248,8 @@ namespace Squidex.Domain.Apps.Entities.Apps |
|
|
|
|
|
|
|
|
sut.RemoveLanguage(CreateCommand(new RemoveLanguage { Language = Language.DE })); |
|
|
sut.RemoveLanguage(CreateCommand(new RemoveLanguage { Language = Language.DE })); |
|
|
|
|
|
|
|
|
|
|
|
Assert.False(sut.State.LanguagesConfig.Contains(Language.DE)); |
|
|
|
|
|
|
|
|
sut.GetUncomittedEvents() |
|
|
sut.GetUncomittedEvents() |
|
|
.ShouldHaveSameEvents( |
|
|
.ShouldHaveSameEvents( |
|
|
CreateEvent(new AppLanguageRemoved { Language = Language.DE }) |
|
|
CreateEvent(new AppLanguageRemoved { Language = Language.DE }) |
|
|
|