Browse Source

Tests improved.

pull/206/head
Sebastian Stehle 8 years ago
parent
commit
220947f6d2
  1. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppCommandMiddlewareTests.cs
  2. 18
      tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppDomainObjectTests.cs
  3. 2
      tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleDequeuerTests.cs

2
tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppCommandMiddlewareTests.cs

@ -26,11 +26,11 @@ namespace Squidex.Domain.Apps.Entities.Apps
private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>(); private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>();
private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>(); private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>();
private readonly IUserResolver userResolver = A.Fake<IUserResolver>(); private readonly IUserResolver userResolver = A.Fake<IUserResolver>();
private readonly AppCommandMiddleware sut;
private readonly AppDomainObject app; private readonly AppDomainObject app;
private readonly Language language = Language.DE; private readonly Language language = Language.DE;
private readonly string contributorId = Guid.NewGuid().ToString(); private readonly string contributorId = Guid.NewGuid().ToString();
private readonly string clientName = "client"; private readonly string clientName = "client";
private readonly AppCommandMiddleware sut;
public AppCommandMiddlewareTests() public AppCommandMiddlewareTests()
{ {

18
tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppDomainObjectTests.cs

@ -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 })

2
tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleDequeuerTests.cs

@ -26,9 +26,9 @@ namespace Squidex.Domain.Apps.Entities.Rules
private readonly ISemanticLog log = A.Fake<ISemanticLog>(); private readonly ISemanticLog log = A.Fake<ISemanticLog>();
private readonly IAppProvider appProvider = A.Fake<IAppProvider>(); private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
private readonly IRuleEventRepository ruleEventRepository = A.Fake<IRuleEventRepository>(); private readonly IRuleEventRepository ruleEventRepository = A.Fake<IRuleEventRepository>();
private readonly Instant now = SystemClock.Instance.GetCurrentInstant();
private readonly RuleService ruleService = A.Fake<RuleService>(); private readonly RuleService ruleService = A.Fake<RuleService>();
private readonly RuleDequeuer sut; private readonly RuleDequeuer sut;
private readonly Instant now = SystemClock.Instance.GetCurrentInstant();
public RuleDequeuerTests() public RuleDequeuerTests()
{ {

Loading…
Cancel
Save