mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using MongoDB.Bson;
|
|
using MongoDB.Bson.IO;
|
|
using MongoDB.Bson.Serialization;
|
|
using Squidex.Domain.Apps.Core.Contents;
|
|
using Squidex.Domain.Apps.Entities.MongoDb.Contents;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
|
|
{
|
|
public sealed class StatusSerializerTests
|
|
{
|
|
private sealed class TestObject
|
|
{
|
|
public Status Status { get; set; }
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_serialize_and_deserialize_status()
|
|
{
|
|
StatusSerializer.Register();
|
|
|
|
var source = new TestObject
|
|
{
|
|
Status = Status.Published
|
|
};
|
|
|
|
var document = new BsonDocument();
|
|
|
|
using (var writer = new BsonDocumentWriter(document))
|
|
{
|
|
BsonSerializer.Serialize(writer, source);
|
|
|
|
writer.Flush();
|
|
}
|
|
|
|
using (var reader = new BsonDocumentReader(document))
|
|
{
|
|
var result = BsonSerializer.Deserialize<TestObject>(reader);
|
|
|
|
Assert.Equal(source.Status, result.Status);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|