2013-03-27 01:17:13 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using FluentAssertions;
|
2013-04-01 03:20:01 +03:00
|
|
|
using Marr.Data;
|
2013-03-27 01:17:13 +03:00
|
|
|
using NUnit.Framework;
|
2013-04-18 02:32:06 +03:00
|
|
|
using NzbDrone.Common;
|
2013-05-12 18:18:17 +03:00
|
|
|
using NzbDrone.Common.Serializer;
|
2013-03-27 01:17:13 +03:00
|
|
|
using NzbDrone.Core.Datastore;
|
2013-04-01 03:20:01 +03:00
|
|
|
using NzbDrone.Core.Datastore.Converters;
|
2013-03-27 01:17:13 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class MappingExtensionFixture
|
|
|
|
{
|
|
|
|
|
|
|
|
public class EmbeddedType : IEmbeddedDocument
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TypeWithAllMappableProperties
|
|
|
|
{
|
|
|
|
public string PropString { get; set; }
|
|
|
|
public int PropInt { get; set; }
|
|
|
|
public bool PropBool { get; set; }
|
|
|
|
public Nullable<int> PropNullable { get; set; }
|
|
|
|
public EmbeddedType Embedded { get; set; }
|
|
|
|
public List<EmbeddedType> EmbeddedList { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TypeWithNoMappableProperties
|
|
|
|
{
|
|
|
|
public Series Series { get; set; }
|
|
|
|
|
|
|
|
public int ReadOnly { get; private set; }
|
|
|
|
public int WriteOnly { private get; set; }
|
|
|
|
}
|
|
|
|
|
2013-04-01 03:20:01 +03:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2013-05-13 05:52:55 +03:00
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<EmbeddedType>), new EmbeddedDocumentConverter());
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(EmbeddedType), new EmbeddedDocumentConverter());
|
2013-04-01 03:20:01 +03:00
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(Int32), new Int32Converter());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-27 01:17:13 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void test_mappable_types()
|
|
|
|
{
|
|
|
|
var properties = typeof(TypeWithAllMappableProperties).GetProperties();
|
|
|
|
properties.Should().NotBeEmpty();
|
|
|
|
properties.Should().OnlyContain(c => MappingExtensions.IsMappableProperty(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void test_un_mappable_types()
|
|
|
|
{
|
|
|
|
var properties = typeof(TypeWithNoMappableProperties).GetProperties();
|
|
|
|
properties.Should().NotBeEmpty();
|
|
|
|
properties.Should().NotContain(c => MappingExtensions.IsMappableProperty(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|