2022-08-30 15:42:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using Newtonsoft.Json;
|
2021-05-13 20:09:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2024-04-09 12:53:23 +02:00
|
|
|
|
using SharedBusinessLogic.Tests.Framework;
|
|
|
|
|
using ShareeBike.Model.State;
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
namespace SharedBusinessLogic.Tests.Fixtures.Bike
|
2021-05-13 20:09:46 +02:00
|
|
|
|
{
|
2022-01-22 18:16:10 +01:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[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");
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
// Serialize object and verify.
|
|
|
|
|
var l_oDetected = JsonConvert.SerializeObject(l_oInfoSource);
|
|
|
|
|
const string EXPECTED = @"
|
2022-01-23 13:08:18 +01:00
|
|
|
|
{
|
|
|
|
|
""From"":""2017 - 09 - 20T23: 05:00"",
|
|
|
|
|
""MailAddress"":""Heinz@mueller"",
|
|
|
|
|
""Code"":""17 xxb""
|
|
|
|
|
}";
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(
|
|
|
|
|
TestHelper.PrepareXmlForStringCompare(l_oDetected.Replace("\n", string.Empty).Replace("\r", string.Empty)), Is.EqualTo(TestHelper.PrepareXmlForStringCompare(EXPECTED.Replace("\n", string.Empty).Replace("\r", string.Empty))));
|
2022-01-22 18:16:10 +01:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
// Deserialize object and verify.
|
|
|
|
|
var l_oInfoTarget = JsonConvert.DeserializeObject<StateOccupiedInfo>(l_oDetected);
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(l_oInfoTarget.Value, Is.EqualTo(InUseStateEnum.Booked));
|
|
|
|
|
Assert.That(l_oInfoTarget.MailAddress, Is.EqualTo("Heinz@mueller"));
|
|
|
|
|
Assert.That(l_oInfoTarget.Code, Is.EqualTo("17 xxb"));
|
|
|
|
|
Assert.That(l_oInfoTarget.From, Is.EqualTo(new DateTime(2017, 9, 20, 23, 5, 0)));
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
}
|