sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/State/TestStateRequestedInfoSerializeJSON.cs

44 lines
1.4 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
using Newtonsoft.Json;
2021-07-12 21:31:46 +02:00
using NUnit.Framework;
using TINK.Model.State;
namespace TestTINKLib.Fixtures.State
{
2022-08-30 15:42:25 +02:00
2021-07-12 21:31:46 +02:00
[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);
}
}
}