Radarr/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs

46 lines
1.4 KiB
C#
Raw Normal View History

2018-11-23 07:03:32 +00:00
using FluentAssertions;
2013-05-01 06:43:14 +00:00
using NUnit.Framework;
2013-05-03 05:24:52 +00:00
using NzbDrone.Core.Annotations;
2013-05-01 06:43:14 +00:00
using NzbDrone.Test.Common;
2019-12-22 22:08:53 +00:00
using Radarr.Http.ClientSchema;
2013-05-01 06:43:14 +00:00
namespace NzbDrone.Api.Test.ClientSchemaTests
{
[TestFixture]
public class SchemaBuilderFixture : TestBase
{
[Test]
public void should_return_field_for_every_property()
{
2013-09-22 23:40:36 +00:00
var schema = SchemaBuilder.ToSchema(new TestModel());
2013-05-01 06:43:14 +00:00
schema.Should().HaveCount(2);
}
[Test]
public void schema_should_have_proper_fields()
{
var model = new TestModel
2019-12-22 22:08:53 +00:00
{
FirstName = "Bob",
LastName = "Poop"
};
2013-05-01 06:43:14 +00:00
2013-09-22 23:40:36 +00:00
var schema = SchemaBuilder.ToSchema(model);
2013-05-01 06:43:14 +00:00
2019-12-22 22:08:53 +00:00
schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string)c.Value == "Poop");
schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string)c.Value == "Bob");
2013-05-01 06:43:14 +00:00
}
}
public class TestModel
{
[FieldDefinition(0, Label = "First Name", HelpText = "Your First Name")]
public string FirstName { get; set; }
[FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name")]
public string LastName { get; set; }
2013-05-03 05:24:52 +00:00
public string Other { get; set; }
2013-05-01 06:43:14 +00:00
}
2018-11-23 07:03:32 +00:00
}