forked from Azure/durabletask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCronTest.cs
More file actions
55 lines (46 loc) · 1.78 KB
/
Copy pathCronTest.cs
File metadata and controls
55 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace DurableTaskSamplesUnitTests
{
using System;
using System.Threading.Tasks;
using DurableTask;
using DurableTask.Test;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DurableTaskSamples.Cron;
[TestClass]
public class CronTest
{
class MockCronTask : TaskActivity<string, string>
{
public static int Count = 0;
public MockCronTask()
{
}
protected override string Execute(DurableTask.TaskContext context, string input)
{
Console.WriteLine("Executing Cron Job. Started At: '" + DateTime.Now.ToString() + "' Number: " + input);
string completed = "Cron Job '" + input + "' Completed...";
Console.WriteLine(completed);
Count++;
return completed;
}
}
[TestMethod]
public async Task CronBasic()
{
OrchestrationTestHost host = new OrchestrationTestHost();
host.ClockSpeedUpFactor = 5;
MockCronTask cronTask = new MockCronTask();
host.AddTaskOrchestrations(typeof(CronOrchestration))
.AddTaskActivities(new MockObjectCreator<TaskActivity>(typeof(CronTask).ToString(), string.Empty, () =>
{
return cronTask;
}));
var result = await host.RunOrchestration<string>(typeof(CronOrchestration), null);
Assert.AreEqual<string>("Done", result);
Assert.AreEqual<double>(4, MockCronTask.Count);
}
}
}