Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

feat(ServiceBus): adds unit tests #197

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
23 changes: 15 additions & 8 deletions Liquid.All.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1000
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.Base", "src\Liquid.Base\Liquid.Base.csproj", "{C53B53BE-BA7D-4C74-B49F-23894B6AA5A6}"
EndProject
Expand Down Expand Up @@ -49,7 +49,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.Domain.Tests", "test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.Tests", "test\Liquid.Tests\Liquid.Tests.csproj", "{6BA7DC4B-0F66-415A-AE74-5DEA5D3943D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.OnAzure.Tests", "test\Liquid.OnAzure.Tests\Liquid.OnAzure.Tests.csproj", "{9DEA4109-7542-40D5-9CCF-A673C9787E6D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.Activation.Tests", "test\Liquid.Activation.Tests\Liquid.Activation.Tests.csproj", "{E5FCB486-0C76-4714-8AC3-3E468FC1DB61}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.OnAzure.Tests", "test\Liquid.OnAzure.Tests\Liquid.OnAzure.Tests.csproj", "{CE80BBAE-350E-444B-A4FD-D9B58C5214E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liquid.Runtime.Tests", "test\Liquid.Runtime.Tests\Liquid.Runtime.Tests.csproj", "{83C12AC3-1AE7-4297-B414-347790EF32A3}"
EndProject
Expand Down Expand Up @@ -115,10 +117,14 @@ Global
{6BA7DC4B-0F66-415A-AE74-5DEA5D3943D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BA7DC4B-0F66-415A-AE74-5DEA5D3943D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BA7DC4B-0F66-415A-AE74-5DEA5D3943D5}.Release|Any CPU.Build.0 = Release|Any CPU
{9DEA4109-7542-40D5-9CCF-A673C9787E6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DEA4109-7542-40D5-9CCF-A673C9787E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DEA4109-7542-40D5-9CCF-A673C9787E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DEA4109-7542-40D5-9CCF-A673C9787E6D}.Release|Any CPU.Build.0 = Release|Any CPU
{E5FCB486-0C76-4714-8AC3-3E468FC1DB61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5FCB486-0C76-4714-8AC3-3E468FC1DB61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5FCB486-0C76-4714-8AC3-3E468FC1DB61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5FCB486-0C76-4714-8AC3-3E468FC1DB61}.Release|Any CPU.Build.0 = Release|Any CPU
{CE80BBAE-350E-444B-A4FD-D9B58C5214E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE80BBAE-350E-444B-A4FD-D9B58C5214E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE80BBAE-350E-444B-A4FD-D9B58C5214E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE80BBAE-350E-444B-A4FD-D9B58C5214E2}.Release|Any CPU.Build.0 = Release|Any CPU
{83C12AC3-1AE7-4297-B414-347790EF32A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83C12AC3-1AE7-4297-B414-347790EF32A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83C12AC3-1AE7-4297-B414-347790EF32A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -142,7 +148,8 @@ Global
{5279F425-0A2C-4889-968D-FFEB25975453} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{90CF0830-CD3C-4DD7-8C90-584772885BE0} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{6BA7DC4B-0F66-415A-AE74-5DEA5D3943D5} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{9DEA4109-7542-40D5-9CCF-A673C9787E6D} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{E5FCB486-0C76-4714-8AC3-3E468FC1DB61} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{CE80BBAE-350E-444B-A4FD-D9B58C5214E2} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
{83C12AC3-1AE7-4297-B414-347790EF32A3} = {6A0B6B3D-15FE-4C0B-97A1-7897E31C0C4E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
7 changes: 7 additions & 0 deletions src/Liquid.Activation/Liquid.Activation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Liquid.Base\Liquid.Base.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Activation/Worker/LightWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class LightWorker : LightBackgroundTask, ILightWorker
protected readonly static Dictionary<MethodInfo, QueueAttribute> _queues = new Dictionary<MethodInfo, QueueAttribute>();
protected readonly static Dictionary<MethodInfo, TopicAttribute> _topics = new Dictionary<MethodInfo, TopicAttribute>();
private readonly List<string> _inputValidationErrors = new List<string>();
protected ILightTelemetry Telemetry { get; } = Workbench.Instance.Telemetry != null ? (ILightTelemetry)Workbench.Instance.Telemetry.CloneService() : null;
protected ILightTelemetry Telemetry => Workbench.Instance.Telemetry;
protected ILightCache Cache => Workbench.Instance.Cache;
//Instance of CriticHandler to inject on the others classes
private readonly CriticHandler _criticHandler = new CriticHandler();
Expand Down
16 changes: 14 additions & 2 deletions src/Liquid.Base/Interfaces/Telemetry/ILightTelemetry.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using Liquid.Base.Interfaces;
// Copyright (c) Avanade Inc. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;

namespace Liquid.Interfaces
{
/// <summary>
/// Service that enables observability for implementers and Liquid itself.
/// </summary>
public interface ILightTelemetry : IWorkbenchService
{
void TrackTrace(params object[] trace);
Expand All @@ -10,7 +16,13 @@ public interface ILightTelemetry : IWorkbenchService
void ComputeMetric(string metricLabel, double value);
void BeginMetricComputation(string metricLabel);
void EndMetricComputation(string metricLabel);
void EnqueueContext(string parentID, object value = null, string operationID = "");
void EnqueueContext(string parentID, object value = null, string operationID = "");
void DequeueContext();

/// <summary>
/// Captures an exception in the telemetry provider.
/// </summary>
/// <param name="exception">The exception to be captured.</param>
void TrackException(Exception exception);
}
}
5 changes: 5 additions & 0 deletions src/Liquid.Base/Workbench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Liquid.Base.Interfaces.Polly;
using Liquid.Interfaces;
Expand All @@ -14,6 +15,10 @@ namespace Liquid
/// Provides a global way to configure a Liquid application.
/// </summary>
[Obsolete("Please use the correct spelled class, Liquid.Base.Workbench")]
[SuppressMessage(
"StyleCop.CSharp.MaintainabilityRules",
"SA1402:File may only contain a single type",
Justification = "Obsolete class will be removed.")]
public static class WorkBench
{
public static ILightRepository Repository => Workbench.Instance.Repository;
Expand Down
8 changes: 4 additions & 4 deletions src/Liquid.OnAWS/MessageBuses/AwsSqsSns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public void ProcessQueue()
catch (Exception exRegister)
{
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exRegister);
Workbench.Instance.Telemetry.TrackException(exRegister);
}
}
}
}
catch (Exception exception)
{
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exception);
Workbench.Instance.Telemetry.TrackException(exception);
}
}
/// <summary>
Expand Down Expand Up @@ -158,15 +158,15 @@ public void ProcessSubscription()
catch (Exception exRegister)
{
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exRegister);
Workbench.Instance.Telemetry.TrackException(exRegister);
}
}
}
}
catch (Exception exception)
{
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exception);
Workbench.Instance.Telemetry.TrackException(exception);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.OnAzure/Databases/CosmosDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public override async Task<IEnumerable<T>> AddOrUpdateAsync<T>(List<T> listModel
}
catch (Exception exRegister)
{
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exRegister);
Workbench.Instance.Telemetry.TrackException(exRegister);
errorEntities.Add(model);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Liquid.OnAzure/Hubs/EventHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private string GetConnection<T>(KeyValuePair<MethodInfo, T> item)
public Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs)
{
//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(exceptionReceivedEventArgs.Exception);
Workbench.Instance.Telemetry.TrackException(exceptionReceivedEventArgs.Exception);
return Task.CompletedTask;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ private void ProcessHub()
Exception moreInfo = new Exception($"Exception reading topic={topic.Value.TopicName} with subscription={topic.Value.Subscription} from event hub. See inner exception for details. Message={exception.Message}", exception);

//Use the class instead of interface because tracking exceptions directly is not supposed to be done outside AMAW (i.e. by the business code)
((LightTelemetry)Workbench.Instance.Telemetry).TrackException(moreInfo);
Workbench.Instance.Telemetry.TrackException(moreInfo);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/Liquid.OnAzure/Liquid.OnAzure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
Expand All @@ -26,6 +29,11 @@
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading