From 3c8843d630c4835baa66408d38daef209a851dc8 Mon Sep 17 00:00:00 2001 From: Bryan Thornbury Date: Wed, 31 Jul 2019 18:10:40 -0700 Subject: [PATCH] Add a function argument test --- Gofer.NET.Tests/GivenARedisTaskQueue.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Gofer.NET.Tests/GivenARedisTaskQueue.cs b/Gofer.NET.Tests/GivenARedisTaskQueue.cs index 6c1b205..8e0d756 100644 --- a/Gofer.NET.Tests/GivenARedisTaskQueue.cs +++ b/Gofer.NET.Tests/GivenARedisTaskQueue.cs @@ -66,26 +66,37 @@ public async Task ItCapturesArgumentsPassedToEnqueuedDelegate() TC(() => LongFunc(long.MaxValue, semaphoreFile), long.MaxValue.ToString()), TC(() => LongFunc(long.MinValue, semaphoreFile), long.MinValue.ToString()), + // Boolean Arguments TC(() => BoolFunc(true, semaphoreFile), true.ToString()), TC(() => BoolFunc(false, semaphoreFile), false.ToString()), + // String Arguments TC(() => StringFunc("astring", semaphoreFile), "astring"), TC(() => StringFunc(variableToExtract, semaphoreFile), variableToExtract), + // Object Arguments TC(() => ObjectFunc(new TestDataHolder {Value = "astring"}, semaphoreFile), "astring"), + // DateTime Arguments TC(() => DateTimeFunc(now, semaphoreFile), now.ToString()), TC(() => DateTimeFunc(utcNow, semaphoreFile), utcNow.ToString()), + // Nullable Type Arguments TC(() => NullableTypeFunc(null, semaphoreFile), "null"), TC(() => NullableTypeFunc(now, semaphoreFile), now.ToString()), + + // Array Arguments TC(() => ArrayFunc1(new[] {"this", "string", "is"}, semaphoreFile), "this,string,is"), TC(() => ArrayFunc2(new[] {1, 2, 3, 4}, semaphoreFile), "1,2,3,4"), TC(() => ArrayFunc3(new int?[] {1, 2, 3, null, 5}, semaphoreFile), "1,2,3,null,5"), + // Type 'Type' Arguments TC(() => TypeFunc(typeof(object), semaphoreFile), typeof(object).ToString()), TC(() => TypeFunc(typeof(GivenARedisTaskQueue), semaphoreFile), typeof(GivenARedisTaskQueue).ToString()), TC(() => TypeFunc(null, semaphoreFile), "null"), + + // Function Arguments + TC(() => FuncFunc(() => 1, semaphoreFile), "1"), // Awaiting inside the lambda is unnecessary, as the method is extracted and serialized. #pragma warning disable 4014 @@ -266,5 +277,10 @@ public void ArrayFunc3(int?[] nums, string semaphoreFile) TaskQueueTestFixture.WriteSemaphoreValue(semaphoreFile, str); } + + public void FuncFunc(Func func, string semaphoreFile) + { + TaskQueueTestFixture.WriteSemaphoreValue(semaphoreFile, func().ToString()); + } } }