Пример #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
        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;
        }