From 53545d9020de2c61a600769ada720fbdf4f48d3c Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Fri, 3 Jan 2025 12:05:12 +0300 Subject: [PATCH] Added DecimalTests --- .../Tests/PrimitiveKeysValuesTests.cs | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs index 685844c067..9a46ea4e33 100644 --- a/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs +++ b/test/EndToEndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/PrimitiveTypesTests/Tests/PrimitiveKeysValuesTests.cs @@ -45,7 +45,7 @@ public override void ConfigureServices(IServiceCollection services) } public PrimitiveKeysValuesTests(TestWebApplicationFactory fixture) - : base(fixture) + : base(fixture) { if (Client.BaseAddress == null) { @@ -108,6 +108,26 @@ public void DateTimeOffsetTest() } } + [Fact] + public void DecimalTest() + { + foreach (var entry in _context.EdmDecimalSet) + { + if(entry.Id == Decimal.MaxValue || entry.Id == Decimal.MinValue) + { + continue; + } + + // Arrange & Act + var query = _context.CreateQuery("EdmDecimalSet").Where(e => e.Id == entry.Id); + var queryResult = query.ToArray(); + + // Assert + //Expected a single result for key value {0}, entry.Id.ToString(CultureInfo.InvariantCulture) + Assert.Single(queryResult); + } + } + [Fact] public void DoubleTest() { @@ -225,14 +245,18 @@ public void TimeTest() #region Private - private static bool IsNotSupportedKey(float key) + private static bool IsNotSupportedKey(object key) { - return float.IsNaN(key); - } + if (key is float keyInFloat) + { + return float.IsNaN(keyInFloat); + } + if (key is double keyInDouble) + { + return double.IsNaN(keyInDouble); + } - private static bool IsNotSupportedKey(double key) - { - return double.IsNaN(key); + return false; } private void ResetDefaultDataSource()