Skip to content

Commit 3b744a9

Browse files
committed
Rework integration project
1 parent 2f31243 commit 3b744a9

File tree

10 files changed

+55
-72
lines changed

10 files changed

+55
-72
lines changed

src/InEngine.Commands/AlwaysSucceed.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class AlwaysSucceed : AbstractCommand
99
{
1010
public override void Run()
1111
{
12+
Info("Ths command always succeeds.");
1213
}
1314
}
1415
}

src/InEngine.Commands/CommandsPlugin.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
using CommandLine;
1+
using System;
2+
using System.Collections.Generic;
3+
using CommandLine;
24
using InEngine.Core;
5+
using InEngine.Core.Commands;
6+
using InEngine.Core.Scheduling;
37

48
namespace InEngine.Commands
59
{
@@ -10,5 +14,29 @@ public class CommandsPlugin : AbstractPlugin
1014

1115
[VerbOption("succeed", HelpText = "A null operation command. Literally does nothing.")]
1216
public AlwaysSucceed Null { get; set; }
17+
18+
public override void Schedule(ISchedule schedule)
19+
{
20+
schedule.Command(new Echo { VerbatimText = "Core Echo command." })
21+
.EverySecond()
22+
.Before(x => Console.WriteLine("Before"))
23+
.After(x => Console.WriteLine("After"))
24+
.PingBefore("http://www.google.com")
25+
.PingAfter("http://www.google.com")
26+
.WriteOutputTo("AlwaysSucceedWrite.log")
27+
.AppendOutputTo("AlwaysSucceedAppend.log")
28+
.EmailOutputTo("example@inengine.net");
29+
30+
schedule.Command(new[] {
31+
new Echo { VerbatimText = "Chain Link 1" },
32+
new Echo { VerbatimText = "Chain Link 2" },
33+
}).EverySecond();
34+
35+
schedule.Command(new List<AbstractCommand> {
36+
new Echo { VerbatimText = "Chain Link A" },
37+
new AlwaysFail(),
38+
new Echo { VerbatimText = "Chain Link C" },
39+
}).EverySecond();
40+
}
1341
}
1442
}

src/InEngine.Core/ServerHost.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
using System;
2+
using InEngine.Core.IO;
23
using InEngine.Core.Queuing;
34
using InEngine.Core.Scheduling;
45

56
namespace InEngine.Core
67
{
7-
public class ServerHost : IDisposable
8+
public class ServerHost : IDisposable, IHasMailSettings, IHasQueueSettings
89
{
910
public SuperScheduler SuperScheduler { get; set; }
1011
public Dequeue Dequeue { get; set; }
11-
public InEngineSettings InEngineSettings { get; set; }
12+
public MailSettings MailSettings { get; set; }
13+
public QueueSettings QueueSettings { get; set; }
1214

13-
public ServerHost()
15+
public void Start()
1416
{
1517
SuperScheduler = new SuperScheduler();
16-
SuperScheduler.Initialize(InEngineSettings.Mail);
18+
SuperScheduler.Initialize(MailSettings);
1719
Dequeue = new Dequeue() {
18-
QueueSettings = InEngineSettings.Queue,
19-
MailSettings = InEngineSettings.Mail,
20+
QueueSettings = QueueSettings,
21+
MailSettings = MailSettings,
2022
};
21-
}
2223

23-
public void Start()
24-
{
2524
SuperScheduler.Start();
2625
StartDequeueAsync();
2726
}

src/InEngine.IntegrationTest/InEngine.IntegrationTest.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<Compile Include="Program.cs" />
4444
<Compile Include="Properties\AssemblyInfo.cs" />
4545
<Compile Include="QueuingTest.cs" />
46-
<Compile Include="SchedulingTest.cs" />
4746
</ItemGroup>
4847
<ItemGroup>
4948
<ProjectReference Include="..\InEngine.Core\InEngine.Core.csproj">
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using InEngine.Core;
23

34
namespace InEngine.IntegrationTest
45
{
@@ -7,14 +8,21 @@ class MainClass
78
public static void Main(string[] args)
89
{
910
Console.WriteLine("------------------------------------------------------------");
10-
Console.WriteLine("Queuing Integration Tests");
11+
Console.WriteLine("Queue Integration Tests");
1112
Console.WriteLine("------------------------------------------------------------");
1213
new QueuingTest().Run();
1314

1415
Console.WriteLine("------------------------------------------------------------");
15-
Console.WriteLine("Scheduling Integration Tests");
16+
Console.WriteLine("Start Server...");
1617
Console.WriteLine("------------------------------------------------------------");
17-
new SchedulingTest().Run();
18+
var settings = InEngineSettings.Make();
19+
var serverHost = new ServerHost() {
20+
MailSettings = settings.Mail,
21+
QueueSettings = settings.Queue,
22+
};
23+
serverHost.Start();
24+
Console.ReadLine();
25+
serverHost.Dispose();
1826
}
1927
}
2028
}

src/InEngine.IntegrationTest/QueuingTest.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ public override void Run()
2929
QueueSettings = settings.Queue,
3030
MailSettings = settings.Mail,
3131
}.Run();
32-
var consume = new Consume {
33-
Count = 1000,
34-
QueueSettings = settings.Queue,
35-
MailSettings = settings.Mail,
36-
};
32+
3733

3834
Enqueue.Command(() => Console.WriteLine("Core lambda command."))
3935
.Dispatch();
@@ -82,8 +78,6 @@ public override void Run()
8278
Enqueue.Commands(Enumerable.Range(0, 10).Select(x => new AlwaysSucceed() as AbstractCommand).ToList())
8379
.Dispatch();
8480

85-
consume.Run();
86-
8781
var queueWriteIntegrationTest = "queueWriteIntegrationTest.txt";
8882
var queueAppendIntegrationTest = "queueAppendIntegrationTest.txt";
8983
File.Delete(queueWriteIntegrationTest);
@@ -98,8 +92,6 @@ public override void Run()
9892
.WriteOutputTo(queueWriteIntegrationTest)
9993
.AppendOutputTo(queueAppendIntegrationTest)
10094
.Dispatch();
101-
102-
consume.Run();
10395
}
10496
}
10597
}

src/InEngine.IntegrationTest/SchedulingTest.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/InEngine.IntegrationTest/appsettings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"InEngine": {
33
"Plugins": {
4+
"InEngine.Commands": ""
45
},
56
"ExecWhitelist": {
7+
"ls": "/bin/ls"
68
},
79
"Mail": {
810
"Host": "localhost",

src/InEngine/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ static void Main(string[] args)
2727
/// </summary>
2828
public static void RunServer()
2929
{
30+
var settings = InEngineSettings.Make();
3031
ServerHost = new ServerHost() {
31-
InEngineSettings = InEngineSettings.Make()
32+
MailSettings = settings.Mail,
33+
QueueSettings = settings.Queue,
3234
};
3335
if (Type.GetType("Mono.Runtime") != null) {
3436
ServerHost.Start();

src/InEngine/appsettings.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"InEngine": {
33
"Plugins": {
4-
"InEngine.Commands": ""
54
},
65
"ExecWhitelist": {
7-
"ls": "/bin/ls"
86
},
97
"Mail": {
108
"Host": "localhost",

0 commit comments

Comments
 (0)