diff --git a/NucuCar.TestClient/NucuCar.TestClient.csproj b/NucuCar.TestClient/NucuCar.TestClient.csproj
deleted file mode 100644
index 22c1d8f..0000000
--- a/NucuCar.TestClient/NucuCar.TestClient.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/NucuCar.TestClient/Program.cs b/NucuCar.TestClient/Program.cs
deleted file mode 100644
index 633bd8b..0000000
--- a/NucuCar.TestClient/Program.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using CommandLine;
-using NucuCar.TestClient.Sensors;
-using NucuCar.TestClient.Telemetry;
-
-namespace NucuCar.TestClient
-{
- internal class Program
- {
- // ReSharper disable once ArrangeTypeMemberModifiers
- static int Main(string[] args)
- {
- return Parser.Default
- .ParseArguments(args)
- .MapResult(
- (SensorsCmd.SensorsCmdOptions opts) =>
- {
- SensorsCmd.RunSensorsTestCommand(opts).GetAwaiter().GetResult();
- return 0;
- },
- (AzureTelemetryPublishCmd.AzureTelemetryPublishOptions opts) =>
- {
- AzureTelemetryPublishCmd.RunAzurePublisherTelemetryTest(opts).GetAwaiter().GetResult();
- return 0;
- },
- (AzureTelemetryReaderCmd.AzureTelemetryReaderOpts opts) =>
- {
- AzureTelemetryReaderCmd.RunAzureTelemetryReaderTest(opts).GetAwaiter().GetResult();
- return 0;
- },
- errs => 1);
- }
- }
-}
\ No newline at end of file
diff --git a/NucuCar.TestClient/Readme.md b/NucuCar.TestClient/Readme.md
deleted file mode 100644
index d84aa51..0000000
--- a/NucuCar.TestClient/Readme.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# NucuCar.TestClient
-
-Command line utility that allows you to play with different car functionality.
-
-````bash
-NucuCar.TestClient 1.0.0
-Copyright (C) 2019 NucuCar.TestClient
-
-ERROR(S):
- No verb selected.
-
- sensors Test the gRPC sensors services.
-
- azure-telemetry-publish Test the publishing telemetry using Microsoft Azure IoT Hub.
-
- azure-telemetry-read Test reading the telemetry using Microsoft Azure's IoT Hub.
-
- help Display more information on a specific command.
-
- version Display version information.
-````
\ No newline at end of file
diff --git a/NucuCar.TestClient/Sensors/SensorsCmd.cs b/NucuCar.TestClient/Sensors/SensorsCmd.cs
deleted file mode 100644
index d892274..0000000
--- a/NucuCar.TestClient/Sensors/SensorsCmd.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-
-using System;
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-using CommandLine;
-using Google.Protobuf.WellKnownTypes;
-using Grpc.Net.Client;
-using Microsoft.Extensions.Logging;
-using NucuCarSensorsProto;
-
-namespace NucuCar.TestClient.Sensors
-{
- public class SensorsCmd
- {
- [Verb("sensors", HelpText = "Test the gRPC sensors services.")]
- public class SensorsCmdOptions
- {
- [Option('u', "url", Required = false, HelpText = "The url and port of the gRPC server.",
- Default = "http://localhost:8000")]
- public string GrpcServiceAddress { get; set; }
-
- [Option('s', "sensor", Required = false, HelpText = "The sensor name you'd like to test.",
- Default = "environment")]
- public string SensorName { get; set; }
- }
-
- public string GrpcServiceAddress { get; set; }
- private static ILogger _logger;
-
- public static async Task RunSensorsTestCommand(SensorsCmdOptions options)
- {
- _logger = LoggerFactory.Create(builder => { builder.AddConsole(); }).CreateLogger();
- var sensorsCommandLine = new SensorsCmd();
- sensorsCommandLine.GrpcServiceAddress = options.GrpcServiceAddress;
-
- switch (options.SensorName)
- {
- case "environment":
- {
- await sensorsCommandLine.EnvironmentSensorGrpcServiceTest();
- break;
- }
- case "health":
- {
- await sensorsCommandLine.HealthSensorGrpcServiceTest();
- break;
- }
- default:
- {
- throw new ArgumentException($"Invalid sensor name: ${options.SensorName}");
- }
- }
- }
-
- private async Task HealthSensorGrpcServiceTest()
- {
- var cts = SetupCancellation();
- var channel = SetupGrpc();
- var client = new HealthSensorGrpcService.HealthSensorGrpcServiceClient(channel);
-
-
- while (true)
- {
- if (cts.Token.IsCancellationRequested)
- {
- break;
- }
-
- await Task.Delay(1000, cts.Token);
-
- var measurementJson = await client.GetCpuTemperatureAsync(new Empty());
- _logger.LogInformation("State: " + measurementJson.State);
- _logger.LogInformation("CpuTemperature: " + measurementJson.JsonData);
- }
- }
-
- public async Task EnvironmentSensorGrpcServiceTest()
- {
- var cts = SetupCancellation();
- var channel = SetupGrpc();
- var client = new EnvironmentSensorGrpcService.EnvironmentSensorGrpcServiceClient(channel);
-
- while (true)
- {
- if (cts.Token.IsCancellationRequested)
- {
- break;
- }
-
- await Task.Delay(1000, cts.Token);
-
- var measurementJson = await client.GetMeasurementAsync(new Empty());
- _logger.LogInformation("State " + measurementJson.State);
- _logger.LogInformation(measurementJson.JsonData);
- }
- }
-
- private static CancellationTokenSource SetupCancellation()
- {
- var cts = new CancellationTokenSource();
-
- Console.CancelKeyPress += (s, e) =>
- {
- e.Cancel = true;
- cts.Cancel();
- Console.WriteLine("Shutting down...");
- };
- return cts;
- }
-
- private GrpcChannel SetupGrpc()
- {
- // Used to allow gRPC calls over unsecured HTTP.
- AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
-
- // Allow untrusted certificates.
- var httpClientHandler = new HttpClientHandler
- {
- ServerCertificateCustomValidationCallback =
- HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
- };
- var httpClient = new HttpClient(httpClientHandler);
-
-
- var channel = GrpcChannel.ForAddress(GrpcServiceAddress,
- new GrpcChannelOptions {HttpClient = httpClient});
- return channel;
- }
- }
-}
\ No newline at end of file
diff --git a/NucuCar.TestClient/Telemetry/AzureTelemetryPublishCmd.cs b/NucuCar.TestClient/Telemetry/AzureTelemetryPublishCmd.cs
deleted file mode 100644
index e57ae7a..0000000
--- a/NucuCar.TestClient/Telemetry/AzureTelemetryPublishCmd.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using CommandLine;
-using Microsoft.Extensions.Logging;
-using Newtonsoft.Json;
-using NucuCar.Telemetry;
-using NucuCar.Telemetry.Abstractions;
-
-namespace NucuCar.TestClient.Telemetry
-{
- public class AzureTelemetryPublishCmd
- {
- [Verb("azure-telemetry-publish", HelpText = "Test the publishing telemetry using Microsoft Azure IoT Hub.")]
- public class AzureTelemetryPublishOptions
- {
- [Option('c', "connectionString", Required = true,
- HelpText = "The publisher's connection string. Get it from the Device.")]
- public string PublisherConnectionString { get; set; }
-
- [Option('m', "message", Required = true, HelpText = "The message to publish")]
- public string PublisherJsonMessage { get; set; }
- }
-
- private class DummyTelemeter : ITelemeter
- {
- private readonly Dictionary _dummyTelemeterData;
-
- public DummyTelemeter(Dictionary dummyData)
- {
- _dummyTelemeterData = dummyData;
- }
-
- public string GetIdentifier()
- {
- return "DummyTelemeter";
- }
-
- public Dictionary GetTelemetryData()
- {
- return _dummyTelemeterData;
- }
-
- public bool IsTelemetryEnabled()
- {
- return true;
- }
- }
-
- public static async Task RunAzurePublisherTelemetryTest(AzureTelemetryPublishOptions opts)
- {
- var logger = LoggerFactory.Create(builder => { builder.AddConsole(); })
- .CreateLogger();
-
- var telemetryPublisher = TelemetryPublisherFactory.Create(TelemetryPublisherType.Azure,
- opts.PublisherConnectionString, "NucuCar.TestClient", logger);
-
- var anonymousTelemeter =
- new DummyTelemeter(
- JsonConvert.DeserializeObject>(opts.PublisherJsonMessage));
-
-
- logger.LogInformation($"Publishing message: {opts.PublisherJsonMessage}");
- telemetryPublisher.RegisterTelemeter(anonymousTelemeter);
- await telemetryPublisher.PublishAsync(CancellationToken.None);
- }
- }
-}
\ No newline at end of file
diff --git a/NucuCar.TestClient/Telemetry/AzureTelemetryReaderCmd.cs b/NucuCar.TestClient/Telemetry/AzureTelemetryReaderCmd.cs
deleted file mode 100644
index 0d44dba..0000000
--- a/NucuCar.TestClient/Telemetry/AzureTelemetryReaderCmd.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using CommandLine;
-using Microsoft.Azure.EventHubs;
-using Microsoft.Extensions.Logging;
-using ILogger = Microsoft.Extensions.Logging.ILogger;
-
-namespace NucuCar.TestClient.Telemetry
-{
- public class AzureTelemetryReaderCmd
- {
- private static ILogger _logger;
-
- [Verb("azure-telemetry-read", HelpText = "Test reading the telemetry using Microsoft Azure's IoT Hub.")]
- public class AzureTelemetryReaderOpts
- {
- [Option('c', "connectionString", Required = true,
- HelpText = "The connection string for the event hub. Get it from 'Build-in endpoints'")]
- public string EventHubConnectionString { get; set; }
- }
-
- private static EventHubClient _eventHubClient;
-
- public static async Task RunAzureTelemetryReaderTest(AzureTelemetryReaderOpts opts)
- {
- _logger = LoggerFactory.Create(builder => { builder.AddConsole(); })
- .CreateLogger();
-
- _eventHubClient = EventHubClient.CreateFromConnectionString(opts.EventHubConnectionString);
-
- var runtimeInfo = await _eventHubClient.GetRuntimeInformationAsync();
- var d2CPartitions = runtimeInfo.PartitionIds;
-
- _logger.LogInformation("Starting reading messages from the Azure IoT Hub... Press Ctrl-C to cancel");
- var cts = new CancellationTokenSource();
- Console.CancelKeyPress += (s, e) =>
- {
- e.Cancel = true;
- cts.Cancel();
- _logger.LogInformation("Exiting...");
- };
-
- var tasks = new List();
- foreach (string partition in d2CPartitions)
- {
- tasks.Add(ReceiveMessagesFromDeviceAsync(partition, cts.Token));
- }
-
- // Wait for all the PartitionReceivers to finsih.
- Task.WaitAll(tasks.ToArray());
- }
-
- // Asynchronously create a PartitionReceiver for a partition and then start
- // reading any messages sent from the simulated client.
- private static async Task ReceiveMessagesFromDeviceAsync(string partition, CancellationToken ct)
- {
- // Create the receiver using the default consumer group.
- // For the purposes of this sample, read only messages sent since
- // the time the receiver is created. Typically, you don't want to skip any messages.
- var eventHubReceiver =
- _eventHubClient.CreateReceiver("$Default", partition, EventPosition.FromEnqueuedTime(DateTime.Now));
- _logger.LogInformation("Create receiver on partition: " + partition);
- while (true)
- {
- if (ct.IsCancellationRequested)
- {
- break;
- }
- _logger.LogInformation("Listening for messages on: " + partition);
- // Check for EventData - this methods times out if there is nothing to retrieve.
- var events = await eventHubReceiver.ReceiveAsync(100);
-
- // If there is data in the batch, process it.
- if (events == null) continue;
-
- foreach (var eventData in events)
- {
- var data = Encoding.UTF8.GetString(eventData.Body.Array);
- _logger.LogInformation($"Message received on partition {partition}:");
- _logger.LogInformation($"Data: {data}:");
- _logger.LogInformation("Application properties (set by device):");
-
- var sb = new StringBuilder();
- foreach (var (key, value) in eventData.Properties)
- {
- sb.Append($"{key}: {value} \r\n");
- _logger.LogInformation(sb.ToString());
- }
-
- sb.Clear();
- _logger.LogInformation("System properties (set by IoT Hub):");
- foreach (var (key, value) in eventData.SystemProperties)
- {
- sb.Append($"{key}: {value},");
- }
-
- _logger.LogInformation(sb.ToString());
- }
- }
- }
- }
-}
\ No newline at end of file