From 3edb8bc2d746bb6c453352703818e4a13968da0b Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Fri, 30 Apr 2021 15:55:11 +0300 Subject: [PATCH] Add support for uint, long types. --- .../FirebaseRestTranslatorTests.cs | 26 +++++++++++++++++++ .../FirebaseRestTranslator.csproj | 2 +- FirebaseRestTranslator/Translator.cs | 10 ++++++- readme.md | 6 +++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/FirebaseRestTranslator.UnitTests/FirebaseRestTranslatorTests.cs b/FirebaseRestTranslator.UnitTests/FirebaseRestTranslatorTests.cs index 2b85b17..271641e 100644 --- a/FirebaseRestTranslator.UnitTests/FirebaseRestTranslatorTests.cs +++ b/FirebaseRestTranslator.UnitTests/FirebaseRestTranslatorTests.cs @@ -86,6 +86,32 @@ namespace FirebaseRestTranslator.UnitTests var actualJson = JsonConvert.SerializeObject(result); Assert.Equal(expectedJson, actualJson); } + + [Fact] + public void Test_FirebaseTranslator_IntegerValue_Uint() + { + var data = new Dictionary() + { + ["myKey"] = (uint) 23 + }; + var expectedJson = "{\"name\":\"Test_FirebaseTranslator\",\"fields\":{\"myKey\":{\"integerValue\":23}}}"; + var result = Translator.Translate("Test_FirebaseTranslator", data); + var actualJson = JsonConvert.SerializeObject(result); + Assert.Equal(expectedJson, actualJson); + } + + [Fact] + public void Test_FirebaseTranslator_IntegerValue_Long() + { + var data = new Dictionary() + { + ["myKey"] = (long) 23 + }; + var expectedJson = "{\"name\":\"Test_FirebaseTranslator\",\"fields\":{\"myKey\":{\"integerValue\":23}}}"; + var result = Translator.Translate("Test_FirebaseTranslator", data); + var actualJson = JsonConvert.SerializeObject(result); + Assert.Equal(expectedJson, actualJson); + } [Fact] public void Test_FirebaseTranslator_DoubleValue() diff --git a/FirebaseRestTranslator/FirebaseRestTranslator.csproj b/FirebaseRestTranslator/FirebaseRestTranslator.csproj index ae5cad3..74b3928 100644 --- a/FirebaseRestTranslator/FirebaseRestTranslator.csproj +++ b/FirebaseRestTranslator/FirebaseRestTranslator.csproj @@ -2,7 +2,7 @@ netcoreapp3.0 FirebaseRestTranslator - 0.1.1 + 0.1.2 Denis Nutiu NucuLabs true diff --git a/FirebaseRestTranslator/Translator.cs b/FirebaseRestTranslator/Translator.cs index 3a27775..cc743e0 100644 --- a/FirebaseRestTranslator/Translator.cs +++ b/FirebaseRestTranslator/Translator.cs @@ -41,10 +41,18 @@ namespace FirebaseRestTranslator { return BuildString(v); } + case uint v: + { + return BuildInteger(v); + } case int v: { return BuildInteger(v); } + case long v: + { + return BuildInteger(v); + } case double v: { return BuildDouble(v); @@ -112,7 +120,7 @@ namespace FirebaseRestTranslator return BuildSimpleValue("stringValue", value); } - private static Dictionary BuildInteger(int value) + private static Dictionary BuildInteger(long value) { return BuildSimpleValue("integerValue", value); } diff --git a/readme.md b/readme.md index ba55233..f1b334e 100644 --- a/readme.md +++ b/readme.md @@ -22,3 +22,9 @@ See the tests for usage. Assert.Equal(expectedJson, actualJson); } ``` + +# Changelog + +### 0.1.2 + +- Added support for uint, long types. \ No newline at end of file