Skip to content

Commit

Permalink
Fix invalid cast in single item source (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillSoss committed Dec 1, 2020
1 parent f912643 commit c8d0c57
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/Runly/Processing/SingleItemSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ internal class SingleItemSource : IItemSource<string>

public Task<string> GetItemIdAsync(string item) => Task.FromResult(item);

public IAsyncEnumerable<string> GetItemsAsync() => (IAsyncEnumerable<string>)new string[] { nameof(Job<Config>.ProcessAsync) }.AsEnumerable();
public IAsyncEnumerable<string> GetItemsAsync() => new string[] { nameof(Job<Config>.ProcessAsync) }.ToAsyncEnumerable();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Runly.Tests.Scenarios.ServiceCollectionConfiguration
namespace Runly.Tests
{
public class Dep1 { }
public class Dep2 { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Runly.Tests.Scenarios.ServiceCollectionConfiguration
namespace Runly.Tests
{
public class AsyncProcessNoConf : Job
public class JobNoConf : Job
{
public AsyncProcessNoConf() : base(new Config()) { }
public JobNoConf() : base(new Config()) { }
public override Task<Result> ProcessAsync() => Task.FromResult(Result.Success());
}

public class AsyncProcessConfOnly : Job<Config>
public class JobSingleItem : Job<Config>
{
public AsyncProcessConfOnly() : base(new Config()) { }
public JobSingleItem() : base(new Config()) { }
public override Task<Result> ProcessAsync() => Task.FromResult(Result.Success());
}

public class AsyncProcess0 : Job<Config, int>
public class Job0 : Job<Config, int>
{
public AsyncProcess0() : base(new Config()) { }
public Job0() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -31,9 +31,9 @@ public override Task<Result> ProcessAsync(int item)
}
}

public class AsyncProcess1 : Job<Config, int, Dep1>
public class Job1 : Job<Config, int, Dep1>
{
public AsyncProcess1() : base(new Config()) { }
public Job1() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -46,9 +46,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1)
}
}

public class AsyncProcess2 : Job<Config, int, Dep1, Dep2>
public class Job2 : Job<Config, int, Dep1, Dep2>
{
public AsyncProcess2() : base(new Config()) { }
public Job2() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -61,9 +61,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2)
}
}

public class AsyncProcess3 : Job<Config, int, Dep1, Dep2, Dep3>
public class Job3 : Job<Config, int, Dep1, Dep2, Dep3>
{
public AsyncProcess3() : base(new Config()) { }
public Job3() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -76,9 +76,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess4 : Job<Config, int, Dep1, Dep2, Dep3, Dep4>
public class Job4 : Job<Config, int, Dep1, Dep2, Dep3, Dep4>
{
public AsyncProcess4() : base(new Config()) { }
public Job4() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -91,9 +91,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess5 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5>
public class Job5 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5>
{
public AsyncProcess5() : base(new Config()) { }
public Job5() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -106,9 +106,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess6 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6>
public class Job6 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6>
{
public AsyncProcess6() : base(new Config()) { }
public Job6() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -121,9 +121,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess7 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7>
public class Job7 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7>
{
public AsyncProcess7() : base(new Config()) { }
public Job7() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -136,9 +136,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess8 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8>
public class Job8 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8>
{
public AsyncProcess8() : base(new Config()) { }
public Job8() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -151,9 +151,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess9 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9>
public class Job9 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9>
{
public AsyncProcess9() : base(new Config()) { }
public Job9() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -166,9 +166,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess10 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10>
public class Job10 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10>
{
public AsyncProcess10() : base(new Config()) { }
public Job10() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -181,9 +181,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess11 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11>
public class Job11 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11>
{
public AsyncProcess11() : base(new Config()) { }
public Job11() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -196,9 +196,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess12 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12>
public class Job12 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12>
{
public AsyncProcess12() : base(new Config()) { }
public Job12() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -211,9 +211,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess13 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13>
public class Job13 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13>
{
public AsyncProcess13() : base(new Config()) { }
public Job13() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -226,9 +226,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess14 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14>
public class Job14 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14>
{
public AsyncProcess14() : base(new Config()) { }
public Job14() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -241,9 +241,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess15 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14, Dep15>
public class Job15 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14, Dep15>
{
public AsyncProcess15() : base(new Config()) { }
public Job15() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand All @@ -256,9 +256,9 @@ public override Task<Result> ProcessAsync(int item, Dep1 arg1, Dep2 arg2, Dep3 a
}
}

public class AsyncProcess16 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14, Dep15, Dep16>
public class Job16 : Job<Config, int, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12, Dep13, Dep14, Dep15, Dep16>
{
public AsyncProcess16() : base(new Config()) { }
public Job16() : base(new Config()) { }

public override IAsyncEnumerable<int> GetItemsAsync()
{
Expand Down
32 changes: 32 additions & 0 deletions test/Runly.Tests/Scenarios/Running/Running_a_job.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using FluentAssertions;
using Runly.Testing;
using System.Threading.Tasks;
using Xunit;

namespace Runly.Tests.Scenarios.Running
{
public class Running_a_job
{
[Fact]
public async Task should_run_a_no_config_job()
{
using var runner = new TestHost<JobNoConf>(new Config()).BuildRunner();

await runner.RunAsync();

runner.Execution.IsComplete.Should().BeTrue();
runner.Execution.Disposition.Should().Be(Disposition.Successful);
}

[Fact]
public async Task should_run_a_single_item_job()
{
using var runner = new TestHost<JobSingleItem>(new Config()).BuildRunner();

await runner.RunAsync();

runner.Execution.IsComplete.Should().BeTrue();
runner.Execution.Disposition.Should().Be(Disposition.Successful);
}
}
}
Loading

0 comments on commit c8d0c57

Please sign in to comment.