2019-12-28 15:09:17 +00:00
|
|
|
using System;
|
2020-04-17 15:11:07 +00:00
|
|
|
using NucuCar.Telemetry;
|
2020-08-01 15:07:13 +00:00
|
|
|
using NucuCar.Telemetry.Publishers;
|
2019-12-28 15:09:17 +00:00
|
|
|
using Xunit;
|
|
|
|
|
2020-08-01 15:32:45 +00:00
|
|
|
namespace NucuCar.UnitTests.NucuCar.Domain.Telemetry.Tests
|
2019-12-28 15:09:17 +00:00
|
|
|
{
|
|
|
|
public class TelemetryPublisherFactoryTest
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
private void Test_Build_TelemetryPublisherAzure()
|
|
|
|
{
|
|
|
|
const string connectionString =
|
|
|
|
"HostName=something.azure-devices.net;DeviceId=something;SharedAccessKey=test";
|
|
|
|
var telemetryPublisher =
|
|
|
|
TelemetryPublisherFactory.CreateFromConnectionString(TelemetryPublisherType.Azure, connectionString);
|
|
|
|
Assert.IsType<TelemetryPublisherAzure>(telemetryPublisher);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
private void Test_Build_TelemetryPublisherDisk()
|
|
|
|
{
|
|
|
|
const string connectionString =
|
|
|
|
"Filename=test;BufferSize=4096";
|
|
|
|
var telemetryPublisher =
|
|
|
|
TelemetryPublisherFactory.CreateFromConnectionString(TelemetryPublisherType.Disk, connectionString);
|
|
|
|
Assert.IsType<TelemetryPublisherDisk>(telemetryPublisher);
|
|
|
|
}
|
2020-04-20 15:19:32 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
private void Test_Build_TelemetryPublisherFiresstore()
|
|
|
|
{
|
|
|
|
const string connectionString =
|
|
|
|
"ProjectId=test;CollectionName=test";
|
|
|
|
var telemetryPublisher =
|
|
|
|
TelemetryPublisherFactory.CreateFromConnectionString(TelemetryPublisherType.Firestore, connectionString);
|
|
|
|
Assert.IsType<TelemetryPublisherFirestore>(telemetryPublisher);
|
|
|
|
}
|
2019-12-28 15:09:17 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
private void Test_Build_ThrowsOnInvalidType()
|
|
|
|
{
|
|
|
|
Assert.Throws<ArgumentException>(() =>
|
|
|
|
{
|
|
|
|
TelemetryPublisherFactory.CreateFromConnectionString("_1", "a=b");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|