Browse Source

Test fixed.

pull/315/head
Sebastian Stehle 8 years ago
parent
commit
8b257edc5d
  1. 12
      tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs
  2. 13
      tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs
  3. 11
      tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs
  4. 10
      tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleGrainTests.cs

12
tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs

@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
.Select(x => new object[] { x }) .Select(x => new object[] { x })
.ToList(); .ToList();
private readonly Rule rule_0 = new Rule(new ContentChangedTrigger(), new FirstAction()); private readonly Rule rule_0 = new Rule(new ContentChangedTrigger(), new TestAction1());
public sealed class OtherTrigger : RuleTrigger public sealed class OtherTrigger : RuleTrigger
{ {
@ -40,12 +40,12 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
} }
} }
public sealed class FirstAction : RuleAction public sealed class TestAction1 : RuleAction
{ {
public string Property { get; set; } public string Property { get; set; }
} }
public sealed class OtherAction : RuleAction public sealed class TestAction2 : RuleAction
{ {
public string Property { get; set; } public string Property { get; set; }
} }
@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
public void Should_create_with_trigger_and_action() public void Should_create_with_trigger_and_action()
{ {
var ruleTrigger = new ContentChangedTrigger(); var ruleTrigger = new ContentChangedTrigger();
var ruleAction = new FirstAction(); var ruleAction = new TestAction1();
var newRule = new Rule(ruleTrigger, ruleAction); var newRule = new Rule(ruleTrigger, ruleAction);
@ -104,7 +104,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
[Fact] [Fact]
public void Should_replace_action_when_updating() public void Should_replace_action_when_updating()
{ {
var newAction = new FirstAction(); var newAction = new TestAction1();
var rule_1 = rule_0.Update(newAction); var rule_1 = rule_0.Update(newAction);
@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules
[Fact] [Fact]
public void Should_throw_exception_when_new_action_has_other_type() public void Should_throw_exception_when_new_action_has_other_type()
{ {
Assert.Throws<ArgumentException>(() => rule_0.Update(new OtherAction())); Assert.Throws<ArgumentException>(() => rule_0.Update(new TestAction2()));
} }
[Fact] [Fact]

13
tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs

@ -24,10 +24,15 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards
public class GuardRuleTests public class GuardRuleTests
{ {
private readonly Uri validUrl = new Uri("https://squidex.io"); private readonly Uri validUrl = new Uri("https://squidex.io");
private readonly Rule rule_0 = new Rule(new ContentChangedTrigger(), new WebhookAction()); private readonly Rule rule_0 = new Rule(new ContentChangedTrigger(), new TestAction());
private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app"); private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app");
private readonly IAppProvider appProvider = A.Fake<IAppProvider>(); private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
public sealed class TestAction : RuleAction
{
public Uri Url { get; set; }
}
public GuardRuleTests() public GuardRuleTests()
{ {
A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, A<Guid>.Ignored, false)) A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, A<Guid>.Ignored, false))
@ -40,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards
var command = CreateCommand(new CreateRule var command = CreateCommand(new CreateRule
{ {
Trigger = null, Trigger = null,
Action = new WebhookAction Action = new TestAction
{ {
Url = validUrl Url = validUrl
} }
@ -75,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards
{ {
Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty
}, },
Action = new WebhookAction Action = new TestAction
{ {
Url = validUrl Url = validUrl
} }
@ -102,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards
{ {
Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty
}, },
Action = new WebhookAction Action = new TestAction
{ {
Url = validUrl Url = validUrl
} }

11
tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs

@ -33,6 +33,11 @@ namespace Squidex.Domain.Apps.Entities.Rules
private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app"); private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app");
private readonly RuleEnqueuer sut; private readonly RuleEnqueuer sut;
public sealed class TestAction : RuleAction
{
public Uri Url { get; set; }
}
public RuleEnqueuerTests() public RuleEnqueuerTests()
{ {
sut = new RuleEnqueuer( sut = new RuleEnqueuer(
@ -65,9 +70,9 @@ namespace Squidex.Domain.Apps.Entities.Rules
{ {
var @event = Envelope.Create(new ContentCreated { AppId = appId }); var @event = Envelope.Create(new ContentCreated { AppId = appId });
var rule1 = new Rule(new ContentChangedTrigger(), new WebhookAction { Url = new Uri("https://squidex.io") }); var rule1 = new Rule(new ContentChangedTrigger(), new TestAction { Url = new Uri("https://squidex.io") });
var rule2 = new Rule(new ContentChangedTrigger(), new WebhookAction { Url = new Uri("https://squidex.io") }); var rule2 = new Rule(new ContentChangedTrigger(), new TestAction { Url = new Uri("https://squidex.io") });
var rule3 = new Rule(new ContentChangedTrigger(), new WebhookAction { Url = new Uri("https://squidex.io") }); var rule3 = new Rule(new ContentChangedTrigger(), new TestAction { Url = new Uri("https://squidex.io") });
var job1 = new RuleJob { Created = now }; var job1 = new RuleJob { Created = now };
var job2 = new RuleJob { Created = now }; var job2 = new RuleJob { Created = now };

10
tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleGrainTests.cs

@ -9,6 +9,7 @@ using System;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Domain.Apps.Core.Rules;
using Squidex.Domain.Apps.Core.Rules.Triggers; using Squidex.Domain.Apps.Core.Rules.Triggers;
using Squidex.Domain.Apps.Entities.Rules.Commands; using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Domain.Apps.Entities.Rules.State; using Squidex.Domain.Apps.Entities.Rules.State;
@ -32,6 +33,11 @@ namespace Squidex.Domain.Apps.Entities.Rules
get { return ruleId; } get { return ruleId; }
} }
public sealed class TestAction : RuleAction
{
public Uri Url { get; set; }
}
public RuleGrainTests() public RuleGrainTests()
{ {
sut = new RuleGrain(Store, A.Dummy<ISemanticLog>(), appProvider); sut = new RuleGrain(Store, A.Dummy<ISemanticLog>(), appProvider);
@ -188,7 +194,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty
}; };
var newAction = new WebhookAction var newAction = new TestAction
{ {
Url = new Uri("https://squidex.io/v2") Url = new Uri("https://squidex.io/v2")
}; };
@ -203,7 +209,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty Schemas = ImmutableList<ContentChangedTriggerSchema>.Empty
}; };
var newAction = new WebhookAction var newAction = new TestAction
{ {
Url = new Uri("https://squidex.io/v2") Url = new Uri("https://squidex.io/v2")
}; };

Loading…
Cancel
Save