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.
63 lines
1.8 KiB
63 lines
1.8 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Linq;
|
|
using Squidex.Infrastructure.Json.Objects;
|
|
using Squidex.Infrastructure.TestHelpers;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Infrastructure.EventSourcing
|
|
{
|
|
public class EnvelopeHeadersTests
|
|
{
|
|
[Fact]
|
|
public void Should_create_headers()
|
|
{
|
|
var headers = new EnvelopeHeaders();
|
|
|
|
Assert.Empty(headers);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_create_headers_as_copy()
|
|
{
|
|
var source = JsonValue.Object().Add("Key1", 123);
|
|
|
|
var headers = new EnvelopeHeaders(source);
|
|
|
|
CompareHeaders(headers, source);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_clone_headers()
|
|
{
|
|
var headers = new EnvelopeHeaders(JsonValue.Object().Add("Key1", 123));
|
|
|
|
var clone = headers.Clone();
|
|
|
|
CompareHeaders(headers, clone);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_serialize_and_deserialize()
|
|
{
|
|
var value = new EnvelopeHeaders(JsonValue.Object().Add("Key1", 123));
|
|
|
|
var deserialized = value.SerializeAndDeserialize();
|
|
|
|
CompareHeaders(deserialized, value);
|
|
}
|
|
|
|
private static void CompareHeaders(JsonObject lhs, JsonObject rhs)
|
|
{
|
|
foreach (var key in lhs.Keys.Concat(rhs.Keys).Distinct())
|
|
{
|
|
Assert.Equal(lhs[key].ToString(), rhs[key].ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|