mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 23:56:26 +01:00
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
using System;
|
|
using TINK.Model.State;
|
|
|
|
|
|
namespace TestTINKLib.Fixtures.State
|
|
{
|
|
|
|
[TestFixture]
|
|
public class TestStateReInquestedfoSerializeJSON
|
|
{
|
|
[Test]
|
|
public void TestSerializeJSON()
|
|
{
|
|
// Create object to test.
|
|
var l_oReservedInfo = new StateRequestedInfo(
|
|
() => new DateTime(2017, 09, 20),
|
|
new DateTime(2017, 09, 19),
|
|
"a@b",
|
|
"372");
|
|
|
|
// Serialize object
|
|
// Serialize object and verify.
|
|
var l_oDetected = JsonConvert.SerializeObject(l_oReservedInfo);
|
|
// Verify xml
|
|
const string EXPECTED = @"{""From"":""2017 - 09 - 19T00: 00:00"",""MailAddress"":""a @b"",""Code"":""372""}";
|
|
Assert.AreEqual(
|
|
TestHelper.PrepareXmlForStringCompare(EXPECTED),
|
|
TestHelper.PrepareXmlForStringCompare(l_oDetected));
|
|
|
|
// Deserialize object.
|
|
var l_oInfoTarge = JsonConvert.DeserializeObject<StateRequestedInfo>(l_oDetected);
|
|
|
|
// Verify state.
|
|
Assert.AreEqual(InUseStateEnum.Reserved, l_oInfoTarge.Value);
|
|
Assert.AreEqual("a@b", l_oInfoTarge.MailAddress);
|
|
Assert.AreEqual("372", l_oInfoTarge.Code);
|
|
Assert.AreEqual(new DateTime(2017, 9, 19, 0, 0, 0), l_oInfoTarge.From);
|
|
}
|
|
|
|
}
|
|
}
|