private TContract CreateProxyContract(Transporter light) { var memebers = ProxyContractFactory.ParseContractInterface(typeof(TContract)); var dispatcher = _contractBuilder.ReceiveDispatcherFactory(); var outputMessages = memebers.GetMethods().Select(m => new MessageTypeInfo { ReturnType = m.Value.ReturnType, ArgumentTypes = m.Value.GetParameters().Select(p => p.ParameterType).ToArray(), MessageId = (short)m.Key }); var inputMessages = memebers.GetProperties().Select(m => new MessageTypeInfo { ArgumentTypes = ReflectionHelper.GetDelegateInfoOrNull(m.Value.PropertyType).ParameterTypes, ReturnType = ReflectionHelper.GetDelegateInfoOrNull(m.Value.PropertyType).ReturnType, MessageId = (short)m.Key }); var messenger = new Messenger( light, SerializerFactory.CreateDefault(_contractBuilder.UserSerializationRules.ToArray()), DeserializerFactory.CreateDefault(_contractBuilder.UserDeserializationRules.ToArray()), outputMessages: outputMessages.ToArray(), inputMessages: inputMessages.ToArray() ); var interlocutor = new Interlocutor(messenger, dispatcher, _contractBuilder.MaxAnswerTimeoutDelay); var contract = ProxyContractFactory.CreateProxyContract <TContract>(interlocutor); return(contract); }
public void ContractWithNonDelegateProperty_CreateT_throwsException() { var stub = new CordInterlocutorMock(); Assert.Throws <InvalidContractMemeberException>( () => ProxyContractFactory.CreateProxyContract <IContractWithNonDelegateProperty>(stub)); }
public void DelegateDoesNotContainAttribute_CreateT_throwsException() { var stub = new CordInterlocutorMock(); Assert.Throws <ContractMemberAttributeMissingException>( () => ProxyContractFactory.CreateProxyContract <IContractWithDelegateWithoutAttribute>(stub)); }
public void AskAndEventCordIdDuplicated_CreateT_throwsException() { var stub = new CordInterlocutorMock(); Assert.Throws <ContractMessageIdDuplicateException>( () => ProxyContractFactory.CreateProxyContract <IContractWithSameAskAndEventId>(stub)); }
public void EmptyContract_Creates() { var stub = new CordInterlocutorMock(); var proxy = ProxyContractFactory.CreateProxyContract <IEmptyContract>(stub); Assert.IsNotNull(proxy); }
public void InitializeProxyContractFactory() { _cordMock = new CordInterlocutorMock(); _contract = ProxyContractFactory.CreateProxyContract <ICallContract2>(_cordMock); }