mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 15:16:34 +01:00
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
using NUnit.Framework;
|
|||
|
using System;
|
|||
|
using TINK.Model.State;
|
|||
|
|
|||
|
|
|||
|
namespace TestTINKLib.Fixtures.Bike
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Moved to TestShareeLib (.Net Core)
|
|||
|
/// </summary>
|
|||
|
[TestFixture]
|
|||
|
public class TestStateBookedInfoSerializeJSON
|
|||
|
{
|
|||
|
[Test]
|
|||
|
public void TestSerializeJSON()
|
|||
|
{
|
|||
|
// Create object to test.
|
|||
|
var l_oInfoSource = new StateOccupiedInfo(
|
|||
|
new DateTime(2017, 09, 20, 23, 05, 0),
|
|||
|
"Heinz@mueller",
|
|||
|
"17 xxb");
|
|||
|
|
|||
|
// Serialize object and verify.
|
|||
|
var l_oDetected = JsonConvert.SerializeObject(l_oInfoSource);
|
|||
|
const string EXPECTED = @"
|
|||
|
{
|
|||
|
""From"":""2017 - 09 - 20T23: 05:00"",
|
|||
|
""MailAddress"":""Heinz@mueller"",
|
|||
|
""Code"":""17 xxb""
|
|||
|
}";
|
|||
|
Assert.AreEqual(
|
|||
|
TestHelper.PrepareXmlForStringCompare(EXPECTED.Replace("\n", string.Empty).Replace("\r", string.Empty)),
|
|||
|
TestHelper.PrepareXmlForStringCompare(l_oDetected.Replace("\n", string.Empty).Replace("\r", string.Empty)));
|
|||
|
|
|||
|
// Deserialize object and verify.
|
|||
|
var l_oInfoTarget = JsonConvert.DeserializeObject<StateOccupiedInfo>(l_oDetected);
|
|||
|
Assert.AreEqual(InUseStateEnum.Booked, l_oInfoTarget.Value);
|
|||
|
Assert.AreEqual("Heinz@mueller", l_oInfoTarget.MailAddress);
|
|||
|
Assert.AreEqual("17 xxb", l_oInfoTarget.Code);
|
|||
|
Assert.AreEqual(new DateTime(2017, 9, 20, 23, 5, 0), l_oInfoTarget.From);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|