Example #1
0
        public void SimplifiedNameForComplexGenericMessage()
        {
            // arrange
            var expectedType       = typeof(ComplexGenericMessage <SimpleMessage, int>);
            var expectedTypeString = "Rebus.Tests.Extensions.ComplexGenericMessage`2[[Rebus.Tests.Extensions.SimpleMessage, Rebus.Tests], [System.Int32, mscorlib]], Rebus.Tests";

            // act
            var actualTypeStringStatic   = typeof(ComplexGenericMessage <SimpleMessage, int>).GetSimpleAssemblyQualifiedName();
            var actualTypeStringInstance = new ComplexGenericMessage <SimpleMessage, int>().GetType().GetSimpleAssemblyQualifiedName();
            var actualTypeStringInstanceRuntimeConstructed = typeof(ComplexGenericMessage <,>).MakeGenericType(typeof(SimpleMessage), typeof(int)).GetSimpleAssemblyQualifiedName();

            var actualTypeStatic   = Type.GetType(actualTypeStringStatic, false);
            var actualTypeInstance = Type.GetType(actualTypeStringInstance, false);
            var actualTypeInstanceRuntimeConstructed = Type.GetType(actualTypeStringInstanceRuntimeConstructed, false);

            Console.WriteLine($@"

actualTypeStringStatic = {actualTypeStringStatic}
actualTypeStringInstance = {actualTypeStringInstance}
actualTypeStringInstanceRuntimeConstructed = {actualTypeStringInstanceRuntimeConstructed}

actualTypeStatic = {actualTypeStatic}
actualTypeInstance = {actualTypeInstance}
actualTypeInstanceRuntimeConstructed = {actualTypeInstanceRuntimeConstructed}
");

            // assert
            Assert.That(actualTypeStringStatic, Is.EqualTo(expectedTypeString));
            Assert.That(actualTypeStringInstance, Is.EqualTo(expectedTypeString));
            Assert.That(actualTypeStringInstanceRuntimeConstructed, Is.EqualTo(expectedTypeString));

            Assert.That(actualTypeStatic, Is.EqualTo(expectedType));
            Assert.That(actualTypeInstance, Is.EqualTo(expectedType));
            Assert.That(actualTypeInstanceRuntimeConstructed, Is.EqualTo(expectedType));
        }
Example #2
0
        public void SimplifiedNameForComplexGenericMessage()
        {
            // arrange
            var expectedType       = typeof(ComplexGenericMessage <SimpleMessage, int>);
            var expectedTypeString = "Rebus.Tests.Extensions.ComplexGenericMessage`2[[Rebus.Tests.Extensions.SimpleMessage, Rebus.Tests], [System.Int32, mscorlib]], Rebus.Tests";

            // act
            var actualTypeStringStatic   = typeof(ComplexGenericMessage <SimpleMessage, int>).GetSimpleAssemblyQualifiedName();
            var actualTypeStringInstance = new ComplexGenericMessage <SimpleMessage, int>().GetType().GetSimpleAssemblyQualifiedName();
            var actualTypeStringInstanceRuntimeConstructed = typeof(ComplexGenericMessage <,>).MakeGenericType(typeof(SimpleMessage), typeof(int)).GetSimpleAssemblyQualifiedName();

            var actualTypeStatic   = Type.GetType(actualTypeStringStatic, false);
            var actualTypeInstance = Type.GetType(actualTypeStringInstance, false);
            var actualTypeInstanceRuntimeConstructed = Type.GetType(actualTypeStringInstanceRuntimeConstructed, false);

            // assert
            actualTypeStringStatic.ShouldBeEquivalentTo(expectedTypeString);
            actualTypeStringInstance.ShouldBeEquivalentTo(expectedTypeString);
            actualTypeStringInstanceRuntimeConstructed.ShouldBeEquivalentTo(expectedTypeString);

            actualTypeStatic.ShouldBeEquivalentTo(expectedType);
            actualTypeInstance.ShouldBeEquivalentTo(expectedType);
            actualTypeInstanceRuntimeConstructed.ShouldBeEquivalentTo(expectedType);
        }