-
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
pmosk
committed
Sep 1, 2023
1 parent
7c66187
commit 7ace58c
Showing
8 changed files
with
145 additions
and
8 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
49 changes: 49 additions & 0 deletions
49
src/filter-value/Filter.Value.Test/Test.DataverseFilterValue/Test.FromInt32.Nullable.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,49 @@ | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
|
||
namespace GarageGroup.Infra.Dataverse.Api.Filter.Value.Test; | ||
|
||
partial class DataverseFilterValueTest | ||
{ | ||
[Theory] | ||
[InlineData(null, "null")] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusFifteen, "-15")] | ||
[InlineData(TestData.PlusFifteen, "15")] | ||
public static void FromNullableInt32Constructor_ExpectActualValueIsEqualToExpectedValue( | ||
int? sourceValue, string expectedValue) | ||
{ | ||
var actual = new DataverseFilterValue(sourceValue); | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null, "null")] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusOne, "-1")] | ||
[InlineData(TestData.PlusFifteen, "15")] | ||
public static void FromNullableInt32_ExpectActualValueIsEqualToExpectedValue( | ||
int? sourceValue, string expectedValue) | ||
{ | ||
var actual = DataverseFilterValue.FromNullableInt32(sourceValue); | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null, "null")] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusFifteen, "-15")] | ||
[InlineData(TestData.One, "1")] | ||
public static void FromNullableInt32Implicit_ExpectActualValueIsEqualToExpectedValue( | ||
int? sourceValue, string expectedValue) | ||
{ | ||
DataverseFilterValue actual = sourceValue; | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/filter-value/Filter.Value.Test/Test.DataverseFilterValue/Test.FromInt32.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,46 @@ | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
|
||
namespace GarageGroup.Infra.Dataverse.Api.Filter.Value.Test; | ||
|
||
partial class DataverseFilterValueTest | ||
{ | ||
[Theory] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusOne, "-1")] | ||
[InlineData(TestData.PlusFifteen, "15")] | ||
public static void FromInt32Constructor_ExpectActualValueIsEqualToExpectedValue( | ||
int sourceValue, string expectedValue) | ||
{ | ||
var actual = new DataverseFilterValue(sourceValue); | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
|
||
[Theory] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusFifteen, "-15")] | ||
[InlineData(TestData.One, "1")] | ||
public static void FromInt32_ExpectActualValueIsEqualToExpectedValue( | ||
int sourceValue, string expectedValue) | ||
{ | ||
var actual = DataverseFilterValue.FromInt32(sourceValue); | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
|
||
[Theory] | ||
[InlineData(TestData.Zero, "0")] | ||
[InlineData(TestData.MinusFifteen, "-15")] | ||
[InlineData(TestData.PlusFifteen, "15")] | ||
public static void FromInt32Implicit_ExpectActualValueIsEqualToExpectedValue( | ||
int sourceValue, string expectedValue) | ||
{ | ||
DataverseFilterValue actual = sourceValue; | ||
var actualValue = actual.Value; | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/filter-value/Filter.Value/DataverseFilterValue/Value.FromInt32.Nullable.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 @@ | ||
namespace GarageGroup.Infra; | ||
|
||
partial class DataverseFilterValue | ||
{ | ||
public DataverseFilterValue(int? value) | ||
=> | ||
Value = InnerBuildValue(value); | ||
|
||
public static DataverseFilterValue FromNullableInt32(int? value) | ||
=> | ||
new(value); | ||
|
||
public static implicit operator DataverseFilterValue(int? value) | ||
=> | ||
new(value); | ||
|
||
private static string InnerBuildValue(int? source) | ||
=> | ||
source is null ? NullValue : InnerBuildValue(source.Value); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/filter-value/Filter.Value/DataverseFilterValue/Value.FromInt32.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 @@ | ||
namespace GarageGroup.Infra; | ||
|
||
partial class DataverseFilterValue | ||
{ | ||
public DataverseFilterValue(int value) | ||
=> | ||
Value = InnerBuildValue(value); | ||
|
||
public static DataverseFilterValue FromInt32(int value) | ||
=> | ||
new(value); | ||
|
||
public static implicit operator DataverseFilterValue(int value) | ||
=> | ||
new(value); | ||
|
||
private static string InnerBuildValue(int source) | ||
=> | ||
source.ToString(); | ||
} |
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