mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 03:27:29 +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,59 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.State;
|
||||
|
||||
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
|
||||
|
||||
namespace TestTINKLib
|
||||
{
|
||||
/// <summary>
|
||||
/// Moved to TestShareeLib (.Net Core)
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class TestBikeSerializeJSON
|
||||
{
|
||||
[Test, Ignore("Disabled because serialization does no more work due to inheritance since commit ec14b93b.")]
|
||||
public void TestConstruct_SerializeJSON_Disposable()
|
||||
{
|
||||
// Create object to test.
|
||||
var l_oBikeSource = new BikeInfoMutable(3, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, p_oDateTimeProvider: () => new DateTime(1970, 1, 1));
|
||||
|
||||
// Verify prerequisites
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeSource.State.Value);
|
||||
Assert.IsNull(l_oBikeSource.State.MailAddress);
|
||||
Assert.IsNull(l_oBikeSource.State.Code);
|
||||
Assert.IsNull(l_oBikeSource.State.From);
|
||||
|
||||
// Serialize object and verify.
|
||||
var l_oDetected = JsonConvert.SerializeObject(l_oBikeSource, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
const string EXPECTED = @"
|
||||
{
|
||||
""Id"": 3,
|
||||
""CurrentStation"": null,
|
||||
""WheelType"": 1,
|
||||
""TypeOfBike"": 1,
|
||||
""State"": {
|
||||
""StateInfoObject"": {
|
||||
""$type"": ""TINK.Model.State.StateAvailableInfo, TINKLib""
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
Assert.AreEqual(
|
||||
TestHelper.PrepareXmlForStringCompare(EXPECTED),
|
||||
TestHelper.PrepareXmlForStringCompare(l_oDetected));
|
||||
|
||||
// Deserialize object.
|
||||
var l_oBikeTarget = JsonConvert.DeserializeObject<BikeInfoMutable>(l_oDetected, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
|
||||
// Verify state.
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeTarget.State.Value);
|
||||
Assert.IsNull(l_oBikeTarget.State.MailAddress);
|
||||
Assert.IsNull(l_oBikeTarget.State.Code);
|
||||
Assert.IsNull(l_oBikeTarget.State.From);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue