public void ClearAll()
        {
            var impl = new HealthServiceImpl();
            impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.SERVING);
            impl.SetStatus("grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.UNKNOWN);

            impl.ClearAll();
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, ""));
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "grpc.test.TestService"));
        }
        public void ClearAll()
        {
            var impl = new HealthServiceImpl();

            impl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.SERVING);
            impl.SetStatus("virtual-host", "", HealthCheckResponse.Types.ServingStatus.UNKNOWN);

            impl.ClearAll();
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "", ""));
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "virtual-host", ""));
        }
        public void ClearAll()
        {
            var impl = new HealthServiceImpl();

            impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.Serving);
            impl.SetStatus("grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.Unknown);

            impl.ClearAll();
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, ""));
            Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "grpc.test.TestService"));
        }
        public async Task Watch_MultipleWatchesForDifferentServices()
        {
            var cts     = new CancellationTokenSource();
            var context = new TestServerCallContext(cts.Token);
            var writer1 = new TestResponseStreamWriter();
            var writer2 = new TestResponseStreamWriter();

            var impl      = new HealthServiceImpl();
            var callTask1 = impl.Watch(new HealthCheckRequest {
                Service = "One"
            }, writer1, context);
            var callTask2 = impl.Watch(new HealthCheckRequest {
                Service = "Two"
            }, writer2, context);

            // Calling Watch on a service that doesn't have a value set will initially return ServiceUnknown
            var nextWriteTask1 = writer1.WrittenMessagesReader.ReadAsync();
            var nextWriteTask2 = writer2.WrittenMessagesReader.ReadAsync();

            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.ServiceUnknown, (await nextWriteTask1).Status);
            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.ServiceUnknown, (await nextWriteTask2).Status);

            nextWriteTask1 = writer1.WrittenMessagesReader.ReadAsync();
            nextWriteTask2 = writer2.WrittenMessagesReader.ReadAsync();
            impl.SetStatus("One", HealthCheckResponse.Types.ServingStatus.Serving);
            impl.SetStatus("Two", HealthCheckResponse.Types.ServingStatus.NotServing);
            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.Serving, (await nextWriteTask1).Status);
            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.NotServing, (await nextWriteTask2).Status);

            nextWriteTask1 = writer1.WrittenMessagesReader.ReadAsync();
            nextWriteTask2 = writer2.WrittenMessagesReader.ReadAsync();
            impl.ClearAll();
            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.ServiceUnknown, (await nextWriteTask1).Status);
            Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.ServiceUnknown, (await nextWriteTask2).Status);

            cts.Cancel();
            await callTask1;
            await callTask2;
        }