Пример #1
0
        private static async Task <double> InvokeRandomAsync(Random random, ICalculatorClientAsync client)
        {
            double result;

            switch (random.Next(3))
            {
            case 0:
                result = await client.AddAsync(random.NextDouble(), random.NextDouble());

                break;

            case 1:
                result = await client.SubtractAsync(random.NextDouble(), random.NextDouble());

                break;

            case 2:
                result = await client.SquareRootAsync(random.NextDouble() - random.NextDouble());

                break;

            default:
                throw new InvalidOperationException("Should never happen.");
            }

            return(result);
        }
Пример #2
0
        public void SquareRoot_with_events_calls_inner()
        {
            CalculatorClientStub clientStub = new CalculatorClientStub();

            clientStub.Results.Enqueue(8.0d);
            ICalculatorClientAsync client = this.CreateClient(clientStub);

            VerifyResult(8.0d, client.SquareRootAsync(7.0d));
            clientStub.VerifyOperation("SquareRoot", 7.0d, 0.0d);
        }
Пример #3
0
        public void Subtract_with_events_calls_inner()
        {
            CalculatorClientStub clientStub = new CalculatorClientStub();

            clientStub.Results.Enqueue(4.0d);
            ICalculatorClientAsync client = this.CreateClient(clientStub);

            VerifyResult(4.0d, client.SubtractAsync(5.0d, 6.0d));
            clientStub.VerifyOperation("Subtract", 5.0d, 6.0d);
        }
Пример #4
0
        public void Add_with_events_calls_inner()
        {
            CalculatorClientStub clientStub = new CalculatorClientStub();

            clientStub.Results.Enqueue(1.0d);
            ICalculatorClientAsync client = this.CreateClient(clientStub);

            VerifyResult(1.0d, client.AddAsync(2.0d, 3.0d));
            clientStub.VerifyOperation("Add", 2.0d, 3.0d);
        }
 public CalculatorClientWithActivity(ICalculatorClientAsync inner, ClientEventSource eventSource, Guid clientId)
 {
     this.inner       = inner;
     this.eventSource = eventSource;
     this.clientId    = clientId;
 }
 public CalculatorClientWithEvents(ICalculatorClientAsync inner, ClientEventSource eventSource)
 {
     this.inner = inner;
     this.eventSource = eventSource;
 }
Пример #7
0
        private static async Task<double> InvokeRandomAsync(Random random, ICalculatorClientAsync client)
        {
            double result;
            switch (random.Next(3))
            {
                case 0:
                    result = await client.AddAsync(random.NextDouble(), random.NextDouble());
                    break;
                case 1:
                    result = await client.SubtractAsync(random.NextDouble(), random.NextDouble());
                    break;
                case 2:
                    result = await client.SquareRootAsync(random.NextDouble() - random.NextDouble());
                    break;
                default:
                    throw new InvalidOperationException("Should never happen.");
            }

            return result;
        }
Пример #8
0
 public CalculatorClientWithEvents(ICalculatorClientAsync inner, ClientEventSource eventSource)
 {
     this.inner       = inner;
     this.eventSource = eventSource;
 }
 public CalculatorClientWithActivity(ICalculatorClientAsync inner, ClientEventSource eventSource, Guid clientId)
 {
     this.inner = inner;
     this.eventSource = eventSource;
     this.clientId = clientId;
 }