Skip to content

Commit

Permalink
Remove files related to Json and Sqlite features in DataStorage
Browse files Browse the repository at this point in the history
Removed various classes and interfaces associated with Json and Sqlite features in the Frank.Libraries.DataStorage namespace, as part of a cleanup and refactoring process. Also deleted test classes for these features. Modified Sqlite related classes have been added.
  • Loading branch information
frankhaugen committed Dec 2, 2023
1 parent e1189da commit 610a63b
Show file tree
Hide file tree
Showing 59 changed files with 2,002 additions and 511 deletions.
20 changes: 10 additions & 10 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
<InvariantGlobalization>true</InvariantGlobalization>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<PackageReadmeFile>readme.md</PackageReadmeFile>
<!-- <PackageReadmeFile>readme.md</PackageReadmeFile>-->
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/frankhaugen/Frank.Libraries</RepositoryUrl>
<PackageProjectUrl>https://github.com/frankhaugen/Frank.Libraries</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageIcon>icon.png</PackageIcon>
<!-- <PackageIcon condition="Exists('icon.png')">icon.png</PackageIcon>-->
<Authors>Frank R. Haugen</Authors>
<Copyright>Copyright (c) 2023 Frank R. Haugen</Copyright>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\icon.png">
<Pack>True</Pack>
<PackagePath>icon.png</PackagePath>
</None>
<None Include="readme.md" Condition="Exists('readme.md')">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<!-- <None Include="..\..\icon.png">-->
<!-- <Pack>True</Pack>-->
<!-- <PackagePath>icon.png</PackagePath>-->
<!-- </None>-->
<!-- <None Include="readme.md" Condition="Exists('readme.md')">-->
<!-- <Pack>True</Pack>-->
<!-- <PackagePath>\</PackagePath>-->
<!-- </None>-->

</ItemGroup>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using FluentAssertions;
using Frank.Libraries.DataStorage.Csv;
using Frank.Libraries.DataStorage.Tests.Shared;
using Microsoft.Extensions.Options;
using Xunit.Abstractions;

namespace Frank.Libraries.DataStorage.Tests.Repositories;

public class CsvRepositoryTests
{
private readonly ITestOutputHelper _outputHelper;

public CsvRepositoryTests(ITestOutputHelper outputHelper) => _outputHelper = outputHelper;

[Fact]
public void Test_CsvRepository_Operations()
{
// Arrange
// Here we are assuming that JsonTable and JsonContext classes are something like this:
var context = new CsvDocument<ExampleClass>(Options.Create<CsvConnection>(new CsvConnection() { CsvDataFolder = "D:\\temp\\" }));
var repository = new CsvRepository<ExampleClass>(context);

var testData1 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test1", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };
var testData2 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test2", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };

// Act: Add some items to the repository
repository.Add(testData1);
repository.Add(testData2);

// Assert
// Check that the items exist in the repository
var item1 = repository.GetById(testData1.Id);
item1.Should()
.NotBeNull();
item1.Should()
.BeEquivalentTo(testData1);

var item2 = repository.GetById(testData2.Id);
item2.Should()
.NotBeNull();
item2.Should()
.BeEquivalentTo(testData2);

// Act: Remove an item from the repository
repository.Delete(testData1.Id);

// Assert
// Check that the item does not exist in the repository
item1 = repository.GetById(testData1.Id);
item1.Should()
.BeNull();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using FluentAssertions;
using Frank.Libraries.DataStorage.Json;
using Frank.Libraries.DataStorage.Tests.Shared;
using Microsoft.Extensions.Options;
using Xunit.Abstractions;

namespace Frank.Libraries.DataStorage.Tests.Repositories;

public class JsonRepositoryTests
{
private readonly ITestOutputHelper _outputHelper;

public JsonRepositoryTests(ITestOutputHelper outputHelper) => _outputHelper = outputHelper;

[Fact]
public void Test_JsonRepository_Operations()
{
// Arrange
// Here we are assuming that JsonTable and JsonContext classes are something like this:
var context = new JsonContext(Options.Create<JsonConnection>(new JsonConnection() { JsonDataFolder = "D:\\temp\\" }));
var repository = new JsonRepository<ExampleClass>(context);

var testData1 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test1", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };
var testData2 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test2", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };

// Act: Add some items to the repository
repository.Add(testData1);
repository.Add(testData2);

// Assert
// Check that the items exist in the repository
var item1 = repository.GetById(testData1.Id);
item1.Should()
.NotBeNull();
item1.Should()
.BeEquivalentTo(testData1);

var item2 = repository.GetById(testData2.Id);
item2.Should()
.NotBeNull();
item2.Should()
.BeEquivalentTo(testData2);

// Act: Remove an item from the repository
repository.Delete(testData1.Id);

// Assert
// Check that the item does not exist in the repository
item1 = repository.GetById(testData1.Id);
item1.Should()
.BeNull();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using FluentAssertions;
using Frank.Libraries.DataStorage.LiteDb;
using Frank.Libraries.DataStorage.Tests.Shared;
using Microsoft.Extensions.Options;
using Xunit.Abstractions;

namespace Frank.Libraries.DataStorage.Tests.Repositories;

public class LiteDbRepositoryTests
{
private readonly ITestOutputHelper _outputHelper;

public LiteDbRepositoryTests(ITestOutputHelper outputHelper) => _outputHelper = outputHelper;

[Fact]
public void Test_XmlRepository_Operations()
{
// Arrange
// Here we are assuming that JsonTable and JsonContext classes are something like this:
var context = new LiteDbDataContext(Options.Create<LiteDbConnection>(new LiteDbConnection() { LiteDbDataFile = "D:\\temp\\ExampleClass.dblite" }));
var repository = new LiteDbRepository<ExampleClass>(context);

var testData1 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test1", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };
var testData2 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test2", DateTime = new DateTime(2021, 1, 1), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };

// Act: Add some items to the repository
repository.Add(testData1);
repository.Add(testData2);
repository.SaveChanges();

// Assert
// Check that the items exist in the repository
var item1 = repository.GetById(testData1.Id);
item1.Should()
.NotBeNull();
item1.Should()
.BeEquivalentTo(testData1);

var item2 = repository.GetById(testData2.Id);
item2.Should()
.NotBeNull();
item2.Should()
.BeEquivalentTo(testData2);

// Delay to make sure the file is saved
Thread.Sleep(5000);

// Act: Remove an item from the repository
repository.Delete(testData1.Id);
repository.SaveChanges();

// Assert
// Check that the item does not exist in the repository
item1 = repository.GetById(testData1.Id);
item1.Should()
.BeNull();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Frank.Libraries.DataStorage.Csv;
using Frank.Libraries.DataStorage.MongoDb;
using Frank.Libraries.DataStorage.Tests.Shared;
using Microsoft.Extensions.Options;
using Mongo2Go;
using Xunit.Abstractions;

namespace Frank.Libraries.DataStorage.Tests.Repositories;

public class MongoDbRepositoryTests
{
private readonly ITestOutputHelper _outputHelper;

public MongoDbRepositoryTests(ITestOutputHelper outputHelper) => _outputHelper = outputHelper;

[Fact]
public void Test_CsvRepository_Operations()
{
// Arrange
// Here we are assuming that JsonTable and JsonContext classes are something like this:
using var runner = MongoDbRunner.Start();
var context = new MongoDbContext(Options.Create<MongoDbConnection>(new MongoDbConnection() { ConnectionString = runner.ConnectionString, DatabaseName = "ExampleClass" }));
var repository = new MongoDbRepository<ExampleClass>(context);

var testData1 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test1", DateTime = new DateTime(2021, 1, 1).AsUtc(), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };
var testData2 = new ExampleClass { Id = Guid.NewGuid(), SomeData = "Test2", DateTime = new DateTime(2021, 1, 1).AsUtc(), DateTimeOffset = new DateTimeOffset(2021, 1, 1, 1, 1, 1, TimeSpan.Zero), TimeSpan = new TimeSpan(1, 2, 3), Boolean = true };

// Act: Add some items to the repository
repository.Add(testData1);
repository.Add(testData2);

// Assert
// Check that the items exist in the repository
var item1 = repository.GetById(testData1.Id);
item1.Should()
.NotBeNull();
item1.Should()
.BeEquivalentTo(testData1);

var item2 = repository.GetById(testData2.Id);
item2.Should()
.NotBeNull();
item2.Should()
.BeEquivalentTo(testData2);

// Act: Remove an item from the repository
repository.Delete(testData1.Id);

// Assert
// Check that the item does not exist in the repository
item1 = repository.GetById(testData1.Id);
item1.Should()
.BeNull();
}
}
Loading

0 comments on commit 610a63b

Please sign in to comment.