-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove files related to Json and Sqlite features in DataStorage
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
1 parent
e1189da
commit 610a63b
Showing
59 changed files
with
2,002 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 0 additions & 111 deletions
111
...rank.Libraries.DataStorage/Frank.Libraries.DataStorage.Tests/Json/JsonDataStorageTests.cs
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
...ibraries.DataStorage/Frank.Libraries.DataStorage.Tests/Repositories/CsvRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...braries.DataStorage/Frank.Libraries.DataStorage.Tests/Repositories/JsonRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...aries.DataStorage/Frank.Libraries.DataStorage.Tests/Repositories/LiteDbRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...ries.DataStorage/Frank.Libraries.DataStorage.Tests/Repositories/MongoDbRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.