Skip to content

Commit 6c15e72

Browse files
author
Jos Hickson
authored
Merge pull request #5 from wintoncode/master
Update from WintonCode master
2 parents 1ea9a82 + f6eb4ac commit 6c15e72

3 files changed

Lines changed: 110 additions & 150 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![NuGet version](https://img.shields.io/nuget/vpre/Winton.Extensions.Threading.Actor.svg)](https://www.nuget.org/packages/Winton.Extensions.Threading.Actor)
77

88
A lightweight implementation of the actor pattern designed to integrate with C#'s `async`/`await` keywords.
9-
It is a richer version of the implementation outlined on [Winton's Tech Blog](https://tech.winton.com/blog/2017/03/a-tpl-actor-pattern).
9+
It is a richer version of the implementation that will be outlined on [Winton's Tech Blog](https://tech.winton.com/blog/2017/03/a-tpl-actor-pattern) later this week.
1010

1111
## Overview
1212

Winton.Extensions.Threading.Actor.Tests.Unit/ActorTests.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,25 +924,30 @@ private void ThrowIfWaitTimesOut(Task task)
924924

925925
private static IActorTaskFactory SetUpTaskFactory()
926926
{
927-
var taskCreator = new ActorTaskFactory();
927+
var realTaskFactory = new ActorTaskFactory();
928928
var taskFactory = Mock.Of<IActorTaskFactory>();
929929

930930
Mock.Get(taskFactory)
931931
.Setup(x => x.Create(It.IsAny<Action<object>>(), It.IsAny<CancellationToken>(), It.IsAny<TaskCreationOptions>(), It.IsAny<object>()))
932-
.Returns<Action<object>, CancellationToken, TaskCreationOptions, object>((action, cancellationToken, taskCreationOptions, state) => taskCreator.Create(action, cancellationToken, taskCreationOptions, state));
932+
.Returns<Action<object>, CancellationToken, TaskCreationOptions, object>((action, cancellationToken, taskCreationOptions, state) => realTaskFactory.Create(action, cancellationToken, taskCreationOptions, state));
933933
Mock.Get(taskFactory)
934934
.Setup(x => x.Create(It.IsAny<Func<object, int>>(), It.IsAny<CancellationToken>(), It.IsAny<TaskCreationOptions>(), It.IsAny<object>()))
935-
.Returns<Func<object, int>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => taskCreator.Create(function, cancellationToken, taskCreationOptions, state));
935+
.Returns<Func<object, int>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => realTaskFactory.Create(function, cancellationToken, taskCreationOptions, state));
936936
Mock.Get(taskFactory)
937937
.Setup(x => x.Create(It.IsAny<Func<object, Task>>(), It.IsAny<CancellationToken>(), It.IsAny<TaskCreationOptions>(), It.IsAny<object>()))
938-
.Returns<Func<object, Task>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => taskCreator.Create(function, cancellationToken, taskCreationOptions, state));
938+
.Returns<Func<object, Task>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => realTaskFactory.Create(function, cancellationToken, taskCreationOptions, state));
939939
Mock.Get(taskFactory)
940940
.Setup(x => x.Create(It.IsAny<Func<object, Task<string>>>(), It.IsAny<CancellationToken>(), It.IsAny<TaskCreationOptions>(), It.IsAny<object>()))
941-
.Returns<Func<object, Task<string>>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => taskCreator.Create(function, cancellationToken, taskCreationOptions, state));
941+
.Returns<Func<object, Task<string>>, CancellationToken, TaskCreationOptions, object>((function, cancellationToken, taskCreationOptions, state) => realTaskFactory.Create(function, cancellationToken, taskCreationOptions, state));
942942
Mock.Get(taskFactory)
943-
.Setup(x => x.FromCompleted()).Returns(taskCreator.FromCompleted);
943+
.Setup(x => x.FromCompleted())
944+
.Returns(realTaskFactory.FromCompleted);
944945
Mock.Get(taskFactory)
945-
.Setup(x => x.FromException(It.IsAny<Exception>())).Returns<Exception>(taskCreator.FromException);
946+
.Setup(x => x.FromException(It.IsAny<Exception>()))
947+
.Returns<Exception>(realTaskFactory.FromException);
948+
Mock.Get(taskFactory)
949+
.Setup(x => x.CreateDelay(It.IsAny<TimeSpan>(), It.IsAny<CancellationToken>()))
950+
.Returns<TimeSpan, CancellationToken>(Task.Delay);
946951

947952
return taskFactory;
948953
}

0 commit comments

Comments
 (0)