public void Constructor_Adapting() { IData data = _dispatcher.For <IData>(_node.Id).New(123); EnumDataAbs enumExist = EnumDataAbs.Exist; EnumDataAbs enumGone = EnumDataAbs.Gone; IDataService service = _dispatcher.For <IDataService>(_node.Id); service.New(new[] { data }, null, new[] { enumExist }); service.New(new[] { data }, enumExist, new[] { enumExist }); Assert.Throws <InvalidCastException>(() => service.New(new[] { data }, enumGone, new[] { enumExist })); service.New(new[] { data }, new[] { enumExist }); Assert.Throws <InvalidCastException>(() => service.New(new[] { data }, new[] { enumGone })); service.New(new List <EnumDataAbs?[]> { new EnumDataAbs?[] { enumExist } }); Assert.Throws <InvalidCastException>(() => service.New(new List <EnumDataAbs?[]> { new EnumDataAbs?[] { enumGone } })); service.New(new List <IData[]> { new[] { data } }); service.New(new List <IData[]> { null }); }
public void Exception_Should_Be_Wrapped() { var service = _dispatcher.For <ISomeService>(_node.Id); Assert.Throws <ArgumentException>(() => service.StartAll()); var ex1 = Assert.Throws <Exception <IServiceException> >(() => service.New(true)); Assert.Equal(nameof(ServiceException), ex1.Abstraction.Description); Assert.Equal(nameof(ServiceException), ex1.Abstraction.Message); Assert.Equal(nameof(ServiceException), ex1.Message); service = service.New(false); var ex2 = Assert.Throws <Exception <IPermissionDeniedException> >(() => service.Work()); Assert.Equal(typeof(PermissionDeniedException).GetHashCode(), ex2.Abstraction.Code); Assert.Equal(nameof(PermissionDeniedException), ex2.Abstraction.Description); Assert.Equal(nameof(PermissionDeniedException), ex2.Abstraction.Message); Assert.Equal(nameof(PermissionDeniedException), ex2.Message); }