mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 20:16:30 +02:00
Legacy testing lib added..
This commit is contained in:
parent
0167fc321f
commit
47ed05837e
118 changed files with 17505 additions and 0 deletions
|
@ -0,0 +1,68 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Bike;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using TINK.Model.State;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
|
||||
|
||||
namespace TestTINKLib
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Moved to TestShareeLib (.Net Core)
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class TestBikeCollectionSerializeJSON
|
||||
{
|
||||
[Test, Ignore("Disabled because serialization does no more work due to inheritance since commit ec14b93b.")]
|
||||
public void Test_SerializeJSON()
|
||||
{
|
||||
var l_oCollSource = new BikeCollectionMutable
|
||||
{
|
||||
new BikeInfoMutable(57, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround)
|
||||
};
|
||||
|
||||
// Verify prerequisites.
|
||||
Assert.AreEqual(1, l_oCollSource.Count);
|
||||
Assert.AreEqual(57, l_oCollSource[0].Id);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oCollSource[0].State.Value);
|
||||
Assert.IsNull(l_oCollSource[0].State.MailAddress);
|
||||
Assert.IsNull(l_oCollSource[0].State.Code);
|
||||
Assert.IsNull(l_oCollSource[0].State.From);
|
||||
|
||||
// Serialize object and verify json
|
||||
var l_oDetected = JsonConvert.SerializeObject(l_oCollSource, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
const string EXPECTED = @"
|
||||
[
|
||||
{
|
||||
""Id"": 57,
|
||||
""CurrentStation"": null,
|
||||
""WheelType"": 1,
|
||||
""TypeOfBike"": 0,
|
||||
""State"": {
|
||||
""StateInfoObject"": {
|
||||
""$type"": ""TINK.Model.State.StateAvailableInfo, TINKLib""
|
||||
}
|
||||
}
|
||||
}
|
||||
]";
|
||||
|
||||
Assert.AreEqual(
|
||||
TestHelper.PrepareXmlForStringCompare(EXPECTED),
|
||||
TestHelper.PrepareXmlForStringCompare(l_oDetected));
|
||||
|
||||
// Deserialize object.
|
||||
var l_oBikeCollectionTarget = JsonConvert.DeserializeObject<BikeCollectionMutable>(l_oDetected, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
|
||||
// Verify state.
|
||||
Assert.AreEqual(1, l_oBikeCollectionTarget.Count);
|
||||
Assert.AreEqual(57, l_oBikeCollectionTarget[0].Id);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeCollectionTarget[0].State.Value);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.MailAddress);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.Code);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.From);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue