-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
9a4a5c0
commit 850ff1f
Showing
7 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
tests/tests/csharp_reference_project/Test.Pattern.Services.Basic.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,14 @@ | ||
using System.Linq; | ||
using My.Company; | ||
using My.Company.Common; | ||
using Xunit; | ||
|
||
public class TestPatternServicesBasic | ||
{ | ||
[Fact] | ||
public void service_basic() | ||
{ | ||
var _ = BasicService.New(); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
tests/tests/csharp_reference_project/Test.Pattern.Services.Callbacks.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,43 @@ | ||
using System.Linq; | ||
using My.Company; | ||
using My.Company.Common; | ||
using Xunit; | ||
|
||
public class TestPatternServicesCallbacks | ||
{ | ||
|
||
[Fact] | ||
public void service_callbacks() | ||
{ | ||
var callbacks = ServiceCallbacks.New(); | ||
var called = false; | ||
|
||
callbacks.CallbackSimple((x) => | ||
{ | ||
called = true; | ||
Assert.Equal(x, 0u); | ||
return x; | ||
}); | ||
|
||
Assert.True(called); | ||
} | ||
|
||
[Fact] | ||
public void service_callbacks_with_slice() | ||
{ | ||
var callbacks = ServiceCallbacks.New(); | ||
var called = false; | ||
var slice = new[] { 1, 2, 3 }; | ||
|
||
callbacks.CallbackWithSlice((x, y) => | ||
{ | ||
Assert.Equal(x, 1); | ||
Assert.Equal(y, 2); | ||
called = true; | ||
return FFIError.Ok; | ||
}, slice); | ||
|
||
Assert.True(called); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
tests/tests/csharp_reference_project/Test.Pattern.Services.Lifetimes.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,27 @@ | ||
using System.Linq; | ||
using My.Company; | ||
using My.Company.Common; | ||
using Xunit; | ||
|
||
public class TestPatternServicesLifetimes | ||
{ | ||
|
||
[Fact] | ||
public void service_lifetimes() | ||
{ | ||
uint value = 123; | ||
var bools = new[] { Bool.True, Bool.True, Bool.False }; | ||
var bytes = new byte[] { 0 }; | ||
|
||
var service = ServiceUsingLifetimes.NewWith(ref value); | ||
|
||
service.Lifetime1(bools); | ||
service.Lifetime2(bools); | ||
|
||
var str = service.ReturnStringAcceptSlice(bytes); | ||
|
||
Assert.True(string.IsNullOrEmpty(str)); | ||
} | ||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
tests/tests/csharp_reference_project/Test.Pattern.Services.MultipleCtors.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,26 @@ | ||
using System; | ||
using System.Linq; | ||
using My.Company; | ||
using My.Company.Common; | ||
using Xunit; | ||
|
||
public class TestPatternServicesMultipleCtors | ||
{ | ||
|
||
[Fact] | ||
public void service_ctors() | ||
{ | ||
ServiceMultipleCtors.NewWith(123); | ||
ServiceMultipleCtors.NewWithout(); | ||
ServiceMultipleCtors.NewWithString("hello world"); | ||
|
||
try | ||
{ | ||
ServiceMultipleCtors.NewFailing(123); | ||
Assert.True(false); | ||
} | ||
catch (InteropException<FFIError>) { } | ||
} | ||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
tests/tests/csharp_reference_project/Test.Pattern.Services.OnPanic.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,20 @@ | ||
using System; | ||
using System.Linq; | ||
using My.Company; | ||
using My.Company.Common; | ||
using Xunit; | ||
|
||
public class TestPatternServicesOnPanic | ||
{ | ||
|
||
[Fact] | ||
public void service_onpanic() | ||
{ | ||
var service = ServiceOnPanic.New(); | ||
|
||
service.ReturnResult(123); | ||
|
||
Assert.Equal(service.ReturnDefaultValue(123u), 123u); | ||
Assert.Equal(service.ReturnUbOnPanic(), "Hello new_with"); | ||
} | ||
} |
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