Add support for uint, long types.
This commit is contained in:
parent
13a4e1f219
commit
3edb8bc2d7
4 changed files with 42 additions and 2 deletions
|
@ -87,6 +87,32 @@ namespace FirebaseRestTranslator.UnitTests
|
|||
Assert.Equal(expectedJson, actualJson);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_FirebaseTranslator_IntegerValue_Uint()
|
||||
{
|
||||
var data = new Dictionary<string, object>()
|
||||
{
|
||||
["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<string, object>()
|
||||
{
|
||||
["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()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<PackageId>FirebaseRestTranslator</PackageId>
|
||||
<Version>0.1.1</Version>
|
||||
<Version>0.1.2</Version>
|
||||
<Authors>Denis Nutiu</Authors>
|
||||
<Company>NucuLabs</Company>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
|
|
|
@ -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<string, object> BuildInteger(int value)
|
||||
private static Dictionary<string, object> BuildInteger(long value)
|
||||
{
|
||||
return BuildSimpleValue("integerValue", value);
|
||||
}
|
||||
|
|
|
@ -22,3 +22,9 @@ See the tests for usage.
|
|||
Assert.Equal(expectedJson, actualJson);
|
||||
}
|
||||
```
|
||||
|
||||
# Changelog
|
||||
|
||||
### 0.1.2
|
||||
|
||||
- Added support for uint, long types.
|
Loading…
Reference in a new issue