mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-24 05:36:29 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
|
@ -0,0 +1,68 @@
|
|||
using NUnit.Framework;
|
||||
using ShareeBike.Model.Bike;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using ShareeBike.Model.State;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BikeInfoMutable = ShareeBike.Model.Bike.BC.BikeInfoMutable;
|
||||
|
||||
namespace SharedBusinessLogic.Tests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Moved to SharedBusinessLogic.Tests (.Net Core)
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class TestBikeCollectionSerializeJSON
|
||||
{
|
||||
[Test, Ignore("Disabled because serialization does no more work due to inheritance since commit ec14b93b.")]
|
||||
public void Test_SerializeJSON()
|
||||
{
|
||||
var l_oCollSource = new BikeCollectionMutable
|
||||
{
|
||||
new BikeInfoMutable(57, false, new List<string> { "ShareeBike" }, WheelType.Two, TypeOfBike.Allround)
|
||||
};
|
||||
|
||||
// Verify prerequisites.
|
||||
Assert.AreEqual(1, l_oCollSource.Count);
|
||||
Assert.AreEqual(57, l_oCollSource[0].Id);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oCollSource[0].State.Value);
|
||||
Assert.IsNull(l_oCollSource[0].State.MailAddress);
|
||||
Assert.IsNull(l_oCollSource[0].State.Code);
|
||||
Assert.IsNull(l_oCollSource[0].State.From);
|
||||
|
||||
// Serialize object and verify json
|
||||
var l_oDetected = JsonConvert.SerializeObject(l_oCollSource, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
const string EXPECTED = @"
|
||||
[
|
||||
{
|
||||
""Id"": 57,
|
||||
""CurrentStation"": null,
|
||||
""WheelType"": 1,
|
||||
""TypeOfBike"": 0,
|
||||
""State"": {
|
||||
""StateInfoObject"": {
|
||||
""$type"": ""ShareeBike.Model.State.StateAvailableInfo, SharedBusinessLogic""
|
||||
}
|
||||
}
|
||||
}
|
||||
]";
|
||||
|
||||
Assert.AreEqual(
|
||||
TestHelper.PrepareXmlForStringCompare(EXPECTED),
|
||||
TestHelper.PrepareXmlForStringCompare(l_oDetected));
|
||||
|
||||
// Deserialize object.
|
||||
var l_oBikeCollectionTarget = JsonConvert.DeserializeObject<BikeCollectionMutable>(l_oDetected, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
|
||||
|
||||
// Verify state.
|
||||
Assert.AreEqual(1, l_oBikeCollectionTarget.Count);
|
||||
Assert.AreEqual(57, l_oBikeCollectionTarget[0].Id);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeCollectionTarget[0].State.Value);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.MailAddress);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.Code);
|
||||
Assert.IsNull(l_oBikeCollectionTarget[0].State.From);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Model.Bike;
|
||||
using ShareeBike.Model.State;
|
||||
|
||||
using BikeInfoMutable = ShareeBike.Model.Bike.BC.BikeInfoMutable;
|
||||
|
||||
namespace SharedBusinessLogic.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Moved to SharedBusinessLogic.Tests (.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> { "ShareeBike" }, 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"": ""ShareeBike.Model.State.StateAvailableInfo, SharedBusinessLogic""
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
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