// ========================================================================== // AssetFieldPropertiesTests.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group // All rights reserved. // ========================================================================== using System; using System.Linq; using System.Reflection; using Xunit; namespace Squidex.Core.Schemas { public class AssetsFieldPropertiesTests { [Fact] public void Should_set_or_freeze_sut() { var sut = new AssetsFieldProperties(); foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; property.SetValue(sut, value); var result = property.GetValue(sut); Assert.Equal(value, result); } sut.Freeze(); foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; Assert.Throws(() => { try { property.SetValue(sut, value); } catch (Exception ex) { throw ex.InnerException; } }); } } } }