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>)); }
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[])); }
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>)); }
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)); }
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[][, ])); }
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> [, ])); }
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> >)); }
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>)); }
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)); }
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*"); }
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*"); }