コード例 #1
0
        public void ItCorrectlyQuesTheHideAndGrowOperationsWhenAItemIsSelectedBeforeTheOtherCompletes()
        {
            var growCallback = new CallbackInterceptor();

            var originalItemToSelect = A.Prompt().Build();
            var itemToSelect1        = A.Prompt().Build();
            var itemToSelect2        = A.Prompt().Build();

            _controller.SelectedItem = originalItemToSelect;
            _controller.Items        = A.Array(originalItemToSelect, itemToSelect1, itemToSelect2);

            _controller.SelectedItem = itemToSelect1;

            _control.Verify(c => c.GrowItem(originalItemToSelect, It.Is <Action>(a => growCallback.Intercept(a))), Times.Exactly(1));
            _control.Verify(c => c.HideItem(itemToSelect1), Times.Exactly(1));

            _controller.SelectedItem = itemToSelect2;

            _control.Verify(c => c.GrowItem(itemToSelect1, It.IsAny <Action>()), Times.Exactly(0));
            _control.Verify(c => c.HideItem(itemToSelect2), Times.Exactly(0));

            growCallback.ExecuteCallback();

            _control.Verify(c => c.GrowItem(itemToSelect1, It.IsAny <Action>()), Times.Exactly(1));
            _control.Verify(c => c.HideItem(itemToSelect2), Times.Exactly(1));
        }
コード例 #2
0
ファイル: MessageHandler.cs プロジェクト: OmerMor/Messageless
 private Delegate tokenToCallbackProxy(string token, Type callbackType, string senderPath)
 {
     var context = new Context{RecipientPath = senderPath, RecipientKey = token};
     var callbackInterceptor = new CallbackInterceptor(context, callbackType, m_transport, m_serializer, m_kernel, m_timeoutManager);
     var callbackMethodInfo = callbackType.GetMethod("Invoke");
     var parameterTypes = callbackMethodInfo.GetParameters()
         .Select(p => p.ParameterType)
         .ToArray();
     var method = callbackInterceptor.GetType().GetMethods()
         .Where(mi => mi.Name == "Intercept")
         .Single(mi =>mi.GetParameters().Count() == parameterTypes.Length);
     if (method.IsGenericMethodDefinition)
         method = method.MakeGenericMethod(parameterTypes);
     var callbackProxy = Delegate.CreateDelegate(callbackType, callbackInterceptor,
                                                 method, throwOnBindFailure: true);
     return callbackProxy;
 }