-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests, fix byte inner type generation
- Loading branch information
1 parent
f44dfa2
commit c030007
Showing
4 changed files
with
215 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Xunit; | ||
|
||
namespace WrapperValueObject.Tests | ||
{ | ||
[WrapperValueObject(typeof(double))] | ||
public readonly partial struct Probability | ||
{ | ||
} | ||
|
||
public class ProbabilityTypeTests | ||
{ | ||
[Fact] | ||
public void Test_Add() | ||
{ | ||
Probability probability = 0.9; | ||
|
||
var result = probability + 0.05; | ||
var result2 = probability + new Probability(0.05); | ||
|
||
Assert.True(result == result2); | ||
Assert.Equal(((double)probability) + 0.05, (double)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 0.9); | ||
} | ||
|
||
[Fact] | ||
public void Test_Subtract() | ||
{ | ||
Probability probability = 0.9; | ||
|
||
var result = probability - 0.05; | ||
var result2 = probability - new Probability(0.05); | ||
|
||
Assert.True(result == result2); | ||
Assert.Equal(((double)probability) - 0.05, (double)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 0.9); | ||
} | ||
|
||
[Fact] | ||
public void Test_Multiply() | ||
{ | ||
Probability probability = 0.9; | ||
|
||
var result = probability * 0.05; | ||
var result2 = probability * new Probability(0.05); | ||
|
||
Assert.True(result == result2); | ||
Assert.Equal(((double)probability) * 0.05, (double)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 0.9); | ||
} | ||
|
||
[Fact] | ||
public void Test_Divide() | ||
{ | ||
Probability probability = 0.9; | ||
|
||
var result = probability / 0.05; | ||
var result2 = probability / new Probability(0.05); | ||
|
||
Assert.True(result == result2); | ||
Assert.Equal(((double)probability) / 0.05, (double)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 0.9); | ||
} | ||
|
||
[Fact] | ||
public void Test_Modulo() | ||
{ | ||
Probability probability = 0.9; | ||
|
||
var result = probability % 0.05; | ||
var result2 = probability % new Probability(0.05); | ||
|
||
Assert.True(result == result2); | ||
Assert.Equal(((double)probability) % 0.05, (double)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 0.9); | ||
} | ||
} | ||
} |
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,82 @@ | ||
using Xunit; | ||
|
||
namespace WrapperValueObject.Tests | ||
{ | ||
[WrapperValueObject(typeof(byte))] | ||
public readonly partial struct Score | ||
{ | ||
} | ||
|
||
public class ScoreTypeTests | ||
{ | ||
[Fact] | ||
public void Test_Add() | ||
{ | ||
Score probability = 10; | ||
|
||
var result = probability + 5; | ||
var result10 = probability + new Score(5); | ||
|
||
Assert.True(result == result10); | ||
Assert.Equal(((byte)probability) + 5, (byte)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 10); | ||
} | ||
|
||
[Fact] | ||
public void Test_Subtract() | ||
{ | ||
Score probability = 10; | ||
|
||
var result = probability - 5; | ||
var result10 = probability - new Score(5); | ||
|
||
Assert.True(result == result10); | ||
Assert.Equal(((byte)probability) - 5, (byte)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 10); | ||
} | ||
|
||
[Fact] | ||
public void Test_Multiply() | ||
{ | ||
Score probability = 10; | ||
|
||
var result = probability * 5; | ||
var result10 = probability * new Score(5); | ||
|
||
Assert.True(result == result10); | ||
Assert.Equal(((byte)probability) * 5, (byte)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 10); | ||
} | ||
|
||
[Fact] | ||
public void Test_Divide() | ||
{ | ||
Score probability = 10; | ||
|
||
var result = probability / 5; | ||
var result10 = probability / new Score(5); | ||
|
||
Assert.True(result == result10); | ||
Assert.Equal(((byte)probability) / 5, (byte)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 10); | ||
} | ||
|
||
[Fact] | ||
public void Test_Modulo() | ||
{ | ||
Score probability = 10; | ||
|
||
var result = probability % 5; | ||
var result10 = probability % new Score(5); | ||
|
||
Assert.True(result == result10); | ||
Assert.Equal(((byte)probability) % 5, (byte)result); | ||
Assert.True(probability != result); | ||
Assert.True(probability == 10); | ||
} | ||
} | ||
} |