Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cronitor.Tests/Builders/CheckBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Cronitor.Constants;
using Cronitor.Scheduling;
using Cronitor.Models.Monitors;

namespace Cronitor.Tests.Builders
{
public class CheckBuilder
{
private readonly string _key = "Key";
private readonly string _schedule = "every 60 seconds";
private readonly ScheduleExpression _schedule = Schedule.Every(60).Seconds;
private readonly string _timezone = "Europe/Stockholm";
private readonly string _url = "https://www.google.se";

Expand Down Expand Up @@ -35,4 +36,4 @@ public Check Build()
};
}
}
}
}
7 changes: 4 additions & 3 deletions Cronitor.Tests/Builders/HeartbeatBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Cronitor.Models.Monitors;
using Cronitor.Scheduling;
using Cronitor.Models.Monitors;

namespace Cronitor.Tests.Builders
{
public class HeartbeatBuilder
{
private readonly string _key = "Key";
private readonly string _schedule = "every 60 seconds";
private readonly ScheduleExpression _schedule = Schedule.Every(60).Seconds;
private readonly string _timezone = "Europe/Stockholm";

public Heartbeat Build()
Expand All @@ -16,4 +17,4 @@ public Heartbeat Build()
};
}
}
}
}
9 changes: 5 additions & 4 deletions Cronitor.Tests/Builders/JobBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Cronitor.Assertions;
using Cronitor.Models.Monitors;
using Cronitor.Scheduling;

namespace Cronitor.Tests.Builders
{
Expand All @@ -13,7 +14,7 @@ public class JobBuilder
private readonly string _group = "Group";
private readonly string _note = "Note";
private readonly string _platform = "Platform";
private string _schedule = "35 0 * * *";
private ScheduleExpression _schedule = Schedule.Cron.Daily(hour: 0, minute: 35);
private readonly int? _scheduleTolerance = 1;
private readonly string _timeZone = "Europe/Stockholm";

Expand All @@ -39,7 +40,7 @@ public JobBuilder Notify(List<string> notify)
return this;
}

public JobBuilder Schedule(string schedule)
public JobBuilder WithSchedule(ScheduleExpression schedule)
{
_schedule = schedule;
return this;
Expand All @@ -64,4 +65,4 @@ public Job Build()
};
}
}
}
}
7 changes: 4 additions & 3 deletions Cronitor.Tests/MonitorTypeTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Cronitor.Constants;
using Cronitor.Models;
using Cronitor.Scheduling;
using Cronitor.Models.Monitors;
using Cronitor.Tests.Helpers;
using System.Collections.Generic;
Expand Down Expand Up @@ -28,7 +29,7 @@ public void ShouldCreateCheckMonitor()
Region.Sydney,
Region.Virginia
};
const string schedule = "every 60 seconds";
var schedule = Schedule.Every(60).Seconds;
const string timezone = "Europe/Stockholm";
const string url = "https://www.google.se";

Expand All @@ -55,7 +56,7 @@ public void ShouldCreateCheckMonitor()
[Fact]
public void ShouldCreateHeartbeatMonitor()
{
const string schedule = "every 60 seconds";
var schedule = Schedule.Every(60).Seconds;
const string timezone = "Europe/Stockholm";

var monitor = new Heartbeat(MonitorKey, schedule)
Expand Down Expand Up @@ -84,7 +85,7 @@ public void ShouldCreateJobMonitor()
"developers",
"administrators"
};
const string schedule = "every 60 seconds";
var schedule = Schedule.Every(60).Seconds;
const string timezone = "Europe/Stockholm";

var monitor = new Job(MonitorKey)
Expand Down
2 changes: 1 addition & 1 deletion Cronitor.Tests/MonitorsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void ShouldExecuteCreateMethod()
};
var monitor = Make.Job
.Notify(notify)
.Schedule("every 60 seconds")
.WithSchedule("every 60 seconds")
.Build();
_httpClient.Setup(x => x.SendAsync<CreateMonitorResponse>(It.IsAny<CreateMonitorRequest>())).Returns(Task.FromResult(new CreateMonitorResponse { Monitors = new List<Monitor> { monitor } }));

Expand Down
3 changes: 2 additions & 1 deletion Cronitor.Tests/Requests/CreateMonitorRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Cronitor.Assertions;
using Cronitor.Constants;
using Cronitor.Scheduling;
using Cronitor.Models;
using Cronitor.Requests;
using Cronitor.Tests.Helpers;
Expand All @@ -17,7 +18,7 @@ public async Task ShouldCreateMonitorRequestAsync(string expected)
{
var monitor = new Monitor("nightly-backup-job")
.With(x => x.Type, MonitorType.Job.ToString())
.With(x => x.Schedule, "0 0 * * *")
.With(x => x.Schedule, Schedule.Cron.Daily())
.With(x => x.Notify, new List<string> { "default" })
.With(x => x.Tags, new List<string> { "nightly" })
.With(x => x.Assertions, new List<AssertionRule> { Assertion.Metric.Duration.LessThan("15min") })
Expand Down
3 changes: 2 additions & 1 deletion Cronitor.Tests/Requests/UpdateMonitorRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Cronitor.Assertions;
using Cronitor.Constants;
using Cronitor.Scheduling;
using Cronitor.Models;
using Cronitor.Requests;
using Cronitor.Tests.Helpers;
Expand All @@ -18,7 +19,7 @@ public async Task ShouldCreateUpdateMonitorRequestAsync(string expected)
{
var monitor = new Monitor("nightly-backup-job")
.With(x => x.Type, MonitorType.Job.ToString())
.With(x => x.Schedule, "0 0 * * *")
.With(x => x.Schedule, Schedule.Cron.Daily())
.With(x => x.Notify, new List<string> { "default" })
.With(x => x.Tags, new List<string> { "nightly" })
.With(x => x.Assertions, new List<AssertionRule> { Assertion.Metric.Duration.LessThan("15min") })
Expand Down
Loading