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.
58 lines
1.9 KiB
58 lines
1.9 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Xml.Linq;
|
|
using FakeItEasy;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.States;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Domain.Users
|
|
{
|
|
public sealed class DefaultXmlRepositoryTests
|
|
{
|
|
private readonly ISnapshotStore<DefaultXmlRepository.State> store = A.Fake<ISnapshotStore<DefaultXmlRepository.State>>();
|
|
private readonly DefaultXmlRepository sut;
|
|
|
|
public DefaultXmlRepositoryTests()
|
|
{
|
|
sut = new DefaultXmlRepository(store);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_read_from_store()
|
|
{
|
|
A.CallTo(() => store.ReadAllAsync(default))
|
|
.Returns(new[]
|
|
{
|
|
new SnapshotResult<DefaultXmlRepository.State>(default, new DefaultXmlRepository.State
|
|
{
|
|
Xml = new XElement("xml").ToString()
|
|
}, 0L),
|
|
new SnapshotResult<DefaultXmlRepository.State>(default, new DefaultXmlRepository.State
|
|
{
|
|
Xml = new XElement("xml").ToString()
|
|
}, 0L)
|
|
}.ToAsyncEnumerable());
|
|
|
|
var xml = sut.GetAllElements();
|
|
|
|
Assert.Equal(2, xml.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_write_to_store()
|
|
{
|
|
var xml = new XElement("xml");
|
|
|
|
sut.StoreElement(xml, "name");
|
|
|
|
A.CallTo(() => store.WriteAsync(A<SnapshotWriteJob<DefaultXmlRepository.State>>.That.Matches(x => x.Key == DomainId.Create("name")), default))
|
|
.MustHaveHappened();
|
|
}
|
|
}
|
|
}
|
|
|