Skip to content

Add a function argument test #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions Gofer.NET.Tests/GivenARedisTaskQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -266,5 +277,10 @@ public void ArrayFunc3(int?[] nums, string semaphoreFile)

TaskQueueTestFixture.WriteSemaphoreValue(semaphoreFile, str);
}

public void FuncFunc(Func<int> func, string semaphoreFile)
{
TaskQueueTestFixture.WriteSemaphoreValue(semaphoreFile, func().ToString());
}
}
}