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.
60 lines
1.8 KiB
60 lines
1.8 KiB
using System.Collections.Generic;
|
|
using Dapper;
|
|
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Core.Datastore;
|
|
using NzbDrone.Core.Datastore.Converters;
|
|
using NzbDrone.Core.Movies;
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
{
|
|
[TestFixture]
|
|
public class TableMapperFixture
|
|
{
|
|
public class EmbeddedType : IEmbeddedDocument
|
|
{
|
|
}
|
|
|
|
public class TypeWithAllMappableProperties
|
|
{
|
|
public string PropString { get; set; }
|
|
public int PropInt { get; set; }
|
|
public bool PropBool { get; set; }
|
|
public int? PropNullable { get; set; }
|
|
public EmbeddedType Embedded { get; set; }
|
|
public List<EmbeddedType> EmbeddedList { get; set; }
|
|
}
|
|
|
|
public class TypeWithNoMappableProperties
|
|
{
|
|
public Movie Movie { get; set; }
|
|
|
|
public int ReadOnly { get; private set; }
|
|
public int WriteOnly { private get; set; }
|
|
}
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<List<EmbeddedType>>());
|
|
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<EmbeddedType>());
|
|
}
|
|
|
|
[Test]
|
|
public void test_mappable_types()
|
|
{
|
|
var properties = typeof(TypeWithAllMappableProperties).GetProperties();
|
|
properties.Should().NotBeEmpty();
|
|
properties.Should().OnlyContain(c => c.IsMappableProperty());
|
|
}
|
|
|
|
[Test]
|
|
public void test_un_mappable_types()
|
|
{
|
|
var properties = typeof(TypeWithNoMappableProperties).GetProperties();
|
|
properties.Should().NotBeEmpty();
|
|
properties.Should().NotContain(c => c.IsMappableProperty());
|
|
}
|
|
}
|
|
}
|