Skip to content

Instantly share code, notes, and snippets.

@rarous
Created December 6, 2013 11:09
Show Gist options
  • Save rarous/7822083 to your computer and use it in GitHub Desktop.
Save rarous/7822083 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Xunit;
using Xunit.Extensions;
namespace MultiConnector.Conventions.Tests
{
using ServiceBus;
using ServiceBus.Messages;
using ServiceBus.Messages.Internal;
public class ServiceBus_Messages : ConventionTestBase
{
[Theory]
[PropertyData("MessageTypes")]
public void ShouldHaveParameterlessContructor(Type type)
{
Assert.True(HasDefaultConstructor(type));
}
[Theory]
[PropertyData("MessageTypes")]
public void ShouldExtendMessageBaseType(Type type)
{
Assert.True(IsAssignableFrom<Message>(type));
}
[Theory]
[PropertyData("MessageTypesProperties")]
public void ShouldHavePropertiesWithParameterlessContructor(Type type, PropertyInfo property)
{
Assert.True(HasDefaultConstructor(property.PropertyType));
}
public static IEnumerable<object[]> MessageTypes
{
get
{
return GetTypesFromSameNamespaceLike<ConnectorRequest>(t => t != typeof(MessageFactory));
}
}
public static IEnumerable<object[]> MessageTypesProperties
{
get
{
return from type in MessageTypes.Select(x => x[0]).Cast<Type>()
from property in type.GetProperties()
let t = property.PropertyType
where t.IsClass
select new object[] { type, property };
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment