-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
global using NUnit.Framework; | ||
global using NUnit.Framework; |
101 changes: 101 additions & 0 deletions
101
ChainSharp.Tests.Unit/UnitTests/ExtractTypeFromMemoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using ChainSharp.Extensions; | ||
using ChainSharp.Workflow; | ||
using FluentAssertions; | ||
using LanguageExt; | ||
|
||
namespace ChainSharp.Tests.Unit.UnitTests; | ||
|
||
public class ExtractTypeFromMemoryTests : TestSetup | ||
{ | ||
[Theory] | ||
public async Task TestExtractTypeFromMemory() | ||
{ | ||
// Arrange | ||
var input = 1; | ||
|
||
var workflow = new TestWorkflow().Activate(input); | ||
|
||
// Act | ||
var result = workflow.ExtractTypeFromMemory<int, int, string>(); | ||
|
||
// Assert | ||
result.Should().Be(input); | ||
workflow.Exception.Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
public async Task TestTupleExtractTypeFromMemory() | ||
{ | ||
// Arrange | ||
var input = 1; | ||
var tupleInput = ("hello", false); | ||
|
||
var workflow = new TestWorkflow().Activate(input, tupleInput); | ||
|
||
// Act | ||
var result = workflow.ExtractTypeFromMemory<(string, bool), int, string>(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Should().Be(tupleInput); | ||
workflow.Exception.Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
public async Task TestTupleExtractTypeFromMemoryTypeInput() | ||
{ | ||
// Arrange | ||
var input = 1; | ||
var tupleInput = ("hello", false); | ||
|
||
var workflow = new TestWorkflow().Activate(input, tupleInput); | ||
|
||
// Act | ||
var result = ((string, bool)?)workflow.ExtractTypeFromMemory(typeof((string, bool))); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Should().Be(tupleInput); | ||
workflow.Exception.Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
public async Task TestInvalidTupleExtractTypeFromMemoryTypeInput() | ||
{ | ||
// Arrange | ||
var input = 1; | ||
var tupleInput = ValueTuple.Create(1); | ||
|
||
var workflow = new TestWorkflow().Activate(input, tupleInput); | ||
|
||
// Act | ||
var result = (ValueTuple<int>?)workflow.ExtractTypeFromMemory(typeof(ValueTuple<int>)); | ||
|
||
// Assert | ||
workflow.Exception.Should().NotBeNull(); | ||
result.Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
public async Task TestInvalidTupleExtractTypeFromMemory() | ||
{ | ||
// Arrange | ||
var input = 1; | ||
var tupleInput = ValueTuple.Create(1); | ||
|
||
var workflow = new TestWorkflow().Activate(input, tupleInput); | ||
|
||
// Act | ||
var result = workflow.ExtractTypeFromMemory<ValueTuple<int>?, int, string>(); | ||
|
||
// Assert | ||
workflow.Exception.Should().NotBeNull(); | ||
result.Should().BeNull(); | ||
} | ||
|
||
private class TestWorkflow : Workflow<int, string> | ||
{ | ||
protected override async Task<Either<Exception, string>> RunInternal(int input) => | ||
Resolve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("ChainSharp.Tests.Unit")] | ||
[assembly: InternalsVisibleTo("ChainSharp.Tests.Unit")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters