Esempio n. 1
0
        public void Dispose_invalidates_connection()
        {
            ConnectionManagerStub   connectionManagerStub = new ConnectionManagerStub();
            ProxyInvoker <IMyProxy> invoker = new ProxyInvoker <IMyProxy>(connectionManagerStub);

            invoker.Dispose();

            Assert.Equal(1, connectionManagerStub.InvalidateCount);
        }
Esempio n. 2
0
        public void Invoke_connects_and_invokes_method_with_result()
        {
            ConnectionManagerStub connectionManagerStub = new ConnectionManagerStub();

            connectionManagerStub.Proxy = new MyProxyStub();
            ProxyInvoker <IMyProxy> invoker = new ProxyInvoker <IMyProxy>(connectionManagerStub);
            object input = new object();

            Task <object> task = invoker.InvokeAsync(p => p.DoAsync(input));

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Same(input, task.Result);
            Assert.Equal(1, connectionManagerStub.ConnectCount);
        }
Esempio n. 3
0
        public void Invoke_connects_and_invokes_method_with_exception_and_invalidates()
        {
            ConnectionManagerStub connectionManagerStub = new ConnectionManagerStub();
            MyProxyStub           proxyStub             = new MyProxyStub();

            connectionManagerStub.Proxy = proxyStub;
            ProxyInvoker <IMyProxy> invoker = new ProxyInvoker <IMyProxy>(connectionManagerStub);

            InvalidTimeZoneException expectedException = new InvalidTimeZoneException("Expected.");

            proxyStub.Exception = expectedException;
            Task <object> task = invoker.InvokeAsync(p => p.DoAsync(new object()));

            Assert.Equal(TaskStatus.Faulted, task.Status);
            AggregateException ae = Assert.IsType <AggregateException>(task.Exception);

            Assert.Equal(1, ae.InnerExceptions.Count);
            Assert.Same(expectedException, ae.InnerExceptions[0]);
            Assert.Equal(1, connectionManagerStub.InvalidateCount);
        }