Skip to content

Commit

Permalink
Adding test cases, database entities, storage fileStores
Browse files Browse the repository at this point in the history
  • Loading branch information
lanmark7 committed Sep 19, 2024
1 parent e6cac6d commit 5e765e6
Show file tree
Hide file tree
Showing 91 changed files with 1,128 additions and 988 deletions.
134 changes: 0 additions & 134 deletions Base/src/ThingsLibrary.Base/Attributes/IndexAttribute.cs

This file was deleted.

19 changes: 19 additions & 0 deletions Base/src/ThingsLibrary.Base/DataType/Extensions/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Reflection;
using ThingsLibrary.DataType.Extensions;

namespace ThingsLibrary.Base.DataType.Extensions
{
public static class AssemblyExtensions
{
public static string AgentString(this Assembly assembly)
{
ArgumentNullException.ThrowIfNull(assembly);

var name = assembly.GetCustomAttribute<AssemblyProductAttribute>()?.Product ?? throw new ArgumentNullException("Assembly Product Name");

var version = assembly.GetName()?.Version ?? throw new ArgumentNullException("Assembly File Version");

return $"{name}/{version.ToDotString()} ({Metrics.MachineMetrics.OsVersion()})";
}
}
}
2 changes: 1 addition & 1 deletion Base/src/ThingsLibrary.Base/Interfaces/IKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface IKey
/// <summary>
/// Record Key
/// </summary>
public string Key { get; set; }
public string Key { get; }
}
}
13 changes: 13 additions & 0 deletions Base/src/ThingsLibrary.Base/Interfaces/ILastEditDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace ThingsLibrary.Interfaces
{
/// <summary>
/// Basic Interface making sure the class has a standard 'PartitionKey' field
/// </summary>
public interface ILastEditDate
{
/// <summary>
/// DateTime (UTC) of last record edit
/// </summary>
public DateTimeOffset UpdatedOn { get; set; }
}
}
2 changes: 1 addition & 1 deletion Base/src/ThingsLibrary.Base/Interfaces/IPartitionKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface IPartitionKey
/// <summary>
/// Data Partition Key
/// </summary>
public string PartitionKey { get; set; }
public string PartitionKey { get; }
}
}
2 changes: 1 addition & 1 deletion Base/src/ThingsLibrary.Base/Interfaces/IRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface IRevisionNumber
/// <summary>
/// Data Partition Key
/// </summary>
public long Revision { get; set; }
public int Revision { get; set; }
}
}
2 changes: 1 addition & 1 deletion Base/src/ThingsLibrary.Base/ThingsLibrary.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ThingsLibrary.Schema.Library" Version="0.2.7" />
<PackageReference Include="ThingsLibrary.Schema.Library" Version="0.2.8" />
</ItemGroup>
</Project>
39 changes: 38 additions & 1 deletion Base/src/ThingsLibrary.Testing/Environment/TestEnvironment.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace ThingsLibrary.Testing.Environment
using Docker.DotNet.Models;
using System.Diagnostics;

namespace ThingsLibrary.Testing.Environment
{
public class TestEnvironment
{
Expand Down Expand Up @@ -59,6 +62,13 @@ public TestEnvironment()

if (!this.UseExistingContainer && this.ContainerOptions != null)
{
//Check to make sure docker is even running
if (!this.IsDockerRunning())
{
Console.WriteLine("DOCKER DAEMON NOT RUNNING!");
return;
}

this.TestContainer = this.ContainerOptions
.GetContainerBuilder()
.Build();
Expand All @@ -81,6 +91,33 @@ public async Task StartAsync()
//TODO: do any other test environment things
}

public bool IsDockerRunning()
{

try
{
var info = new ProcessStartInfo()
{
FileName = "docker",
Arguments = "ps",
RedirectStandardOutput = true
};

using (var process = Process.Start(info))
{
if (process is null) { return false; }
process.WaitForExit(TimeSpan.FromSeconds(10));

// exit code = 0 is success
return (process.ExitCode == 0);
}
}
catch
{
return false;
}
}

#region --- Cleanup / Dispose ---

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNet.Testcontainers.Builders;
using Microsoft.Extensions.Configuration;
using ThingsLibrary.Testing.Environment;

namespace ThingsLibrary.Testing.Extensions
Expand Down
4 changes: 2 additions & 2 deletions Base/src/ThingsLibrary.Testing/ThingsLibrary.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="Testcontainers" Version="3.9.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="Testcontainers" Version="3.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
18 changes: 0 additions & 18 deletions Database/ThingsLibrary.Database.Cosmos/DataContext.cs

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions Database/ThingsLibrary.Database.Cosmos/Usings.cs

This file was deleted.

28 changes: 0 additions & 28 deletions Database/ThingsLibrary.Database.Mongo/DataContext.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5e765e6

Please sign in to comment.