Created
December 6, 2013 11:09
-
-
Save rarous/7822083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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