Headless CMS and Content Managment Hub
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.
 
 
 
 
 

50 lines
1.5 KiB

// ==========================================================================
// FieldRegistryTests.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Domain.Apps.Core.Schemas
{
public class FieldRegistryTests
{
private readonly FieldRegistry sut = new FieldRegistry(new TypeNameRegistry());
private sealed class InvalidProperties : FieldProperties
{
public override JToken GetDefaultValue()
{
return null;
}
protected override IEnumerable<ValidationError> ValidateCore()
{
yield break;
}
}
[Fact]
public void Should_throw_exception_if_creating_field_and_field_is_not_registered()
{
Assert.Throws<InvalidOperationException>(() => sut.CreateField(1, "name", Partitioning.Invariant, new InvalidProperties()));
}
[Fact]
public void Should_create_field_by_properties()
{
var properties = new NumberFieldProperties();
var field = sut.CreateField(1, "name", Partitioning.Invariant, properties);
Assert.Equal(properties, field.RawProperties);
}
}
}