예제 #1
0
        public void Should_resolve_nested_generics()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType("MyParentGeneric<Int32, bool>+MyNestedGeneric<string>", new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyParentGeneric <Int32, bool> .MyNestedGeneric <string>));
        }
예제 #2
0
        public void Should_resolve_array_type_by_name()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType("MySecondEvent[]", new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MySecondEvent[]));
        }
예제 #3
0
        public void Should_resolve_nestedType_as_generic_param_type_by_name()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType("MyGenericType<MySecondEvent+MyNestedClass>", new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyGenericType <MySecondEvent.MyNestedClass>));
        }
예제 #4
0
        public void Should_handle_nested_type()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType(sut.GetTypeId(typeof(MySecondEvent.MyNestedClass)), new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MySecondEvent.MyNestedClass));
        }
예제 #5
0
        public void Should_handle_multi_dimensional_array()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType(sut.GetTypeId(typeof(MySecondEvent[][, ])), new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MySecondEvent[][, ]));
        }
예제 #6
0
        public void Should_handle_compound_generic_array()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType(sut.GetTypeId(typeof(MyGenericType <MySecondEvent> [, ])), new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyGenericType <MySecondEvent> [, ]));
        }
예제 #7
0
        public void Should_resolve_compound_generic_type_by_name()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType("MyGenericType<string, MyGenericType<MySecondEvent>>", new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyGenericType <string, MyGenericType <MySecondEvent> >));
        }
예제 #8
0
        public void Should_handle_generic_type()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType(sut.GetTypeId(typeof(MyGenericType <string>)), new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyGenericType <string>));
        }
예제 #9
0
        public void Should_resolve_type_by_attribute()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            var messageType = sut.ResolveType("TestMessageType", new[] { Assembly.GetExecutingAssembly() });

            //Assert
            messageType.Should().Be(typeof(MyEvent));
        }
예제 #10
0
        public void Should_fail_resolve_when_multiple_types_by_name()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            void Action()
            {
                sut.ResolveType("SameName", new[] { Assembly.GetExecutingAssembly() });
            }

            //Assert
            ((Action)Action).Should().Throw <ApplicationException>().WithMessage("*multiple*");
        }
예제 #11
0
        public void Should_fail_resolve_when_type_not_found()
        {
            //Arrange
            var sut = new DefaultMessageTypeRegistry();

            //Act
            void Action()
            {
                sut.ResolveType("MyNotFoundEvent", new[] { Assembly.GetExecutingAssembly() });
            }

            //Assert
            ((Action)Action).Should().Throw <ApplicationException>().WithMessage("*could not be resolved*");
        }