2018-03-14 20:41:36 +00:00
|
|
|
using System.Collections.Generic;
|
2013-03-26 22:17:13 +00:00
|
|
|
using FluentAssertions;
|
2019-12-18 02:17:47 +00:00
|
|
|
using Marr.Data;
|
2013-03-26 22:17:13 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-04-01 00:20:01 +00:00
|
|
|
using NzbDrone.Core.Datastore.Converters;
|
2019-12-18 02:17:47 +00:00
|
|
|
using NzbDrone.Core.Datastore.Extensions;
|
2018-03-14 20:41:36 +00:00
|
|
|
using NzbDrone.Core.Movies;
|
2013-03-26 22:17:13 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-12-18 02:17:47 +00:00
|
|
|
public class MappingExtensionFixture
|
2013-03-26 22:17:13 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public class EmbeddedType : IEmbeddedDocument
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TypeWithAllMappableProperties
|
|
|
|
{
|
|
|
|
public string PropString { get; set; }
|
|
|
|
public int PropInt { get; set; }
|
|
|
|
public bool PropBool { get; set; }
|
2015-10-03 19:19:25 +00:00
|
|
|
public int? PropNullable { get; set; }
|
2013-03-26 22:17:13 +00:00
|
|
|
public EmbeddedType Embedded { get; set; }
|
|
|
|
public List<EmbeddedType> EmbeddedList { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TypeWithNoMappableProperties
|
|
|
|
{
|
2018-03-14 20:41:36 +00:00
|
|
|
public Movie Movie { get; set; }
|
2013-03-26 22:17:13 +00:00
|
|
|
|
|
|
|
public int ReadOnly { get; private set; }
|
|
|
|
public int WriteOnly { private get; set; }
|
|
|
|
}
|
|
|
|
|
2013-04-01 00:20:01 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2019-12-18 02:17:47 +00:00
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<EmbeddedType>), new EmbeddedDocumentConverter());
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(EmbeddedType), new EmbeddedDocumentConverter());
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(int), new Int32Converter());
|
2019-12-22 21:24:11 +00:00
|
|
|
|
2013-04-01 00:20:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 02:17:47 +00:00
|
|
|
|
2013-03-26 22:17:13 +00:00
|
|
|
[Test]
|
|
|
|
public void test_mappable_types()
|
|
|
|
{
|
|
|
|
var properties = typeof(TypeWithAllMappableProperties).GetProperties();
|
|
|
|
properties.Should().NotBeEmpty();
|
2019-12-18 02:17:47 +00:00
|
|
|
properties.Should().OnlyContain(c => MappingExtensions.IsMappableProperty(c));
|
2013-03-26 22:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void test_un_mappable_types()
|
|
|
|
{
|
|
|
|
var properties = typeof(TypeWithNoMappableProperties).GetProperties();
|
|
|
|
properties.Should().NotBeEmpty();
|
2019-12-18 02:17:47 +00:00
|
|
|
properties.Should().NotContain(c => MappingExtensions.IsMappableProperty(c));
|
2013-03-26 22:17:13 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-14 20:41:36 +00:00
|
|
|
}
|