Skip to content

Commit f1d15ac

Browse files
Merge pull request #86 from johelvisguzman/filebased
Corrected the name of the file that is generated when only the directory is provided
2 parents 4234231 + f791e57 commit f1d15ac

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/DotNetToolkit.Repository.InMemory/InMemoryRepositoryFileBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace DotNetToolkit.Repository.InMemory
22
{
33
using FetchStrategies;
4+
using Helpers;
45
using Logging;
56
using Properties;
67
using System;
@@ -81,7 +82,7 @@ private string ValidateFile(string filePath)
8182
if (!fileName.EndsWith(@"\"))
8283
fileName += @"\";
8384

84-
fileName += $"{GetType().Name}{FileExtension}";
85+
fileName += $"{typeof(TEntity).GetTableName()}{FileExtension}";
8586
}
8687
else
8788
{

test/DotNetToolkit.Repository.Integration.Test/InMemoryFiledBaseRepositoryTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.IO;
66
using System.Reflection;
7+
using Helpers;
78
using Xunit;
89

910
public class InMemoryFiledBaseRepositoryTests : TestBase
@@ -54,11 +55,13 @@ private static void TestCreatesTempFileOnConstruction(IRepository<Customer, int>
5455

5556
private static void TestGeneratesTempFileNameWhenOnlyDirectoryIsProvided(IRepository<Customer, int> repo)
5657
{
57-
var path = GetTempFileName($"{typeof(Customer).Name}" + GetFileExtension(repo));
58+
var dir = GetTempFileName(string.Empty);
59+
var defaultGeneratedPathName = typeof(Customer).GetTableName() + GetFileExtension(repo);
60+
var path = dir + defaultGeneratedPathName;
5861

5962
Assert.True(!File.Exists(path));
6063

61-
repo = CreateRepositoryInstanceOfType(repo.GetType(), path);
64+
repo = CreateRepositoryInstanceOfType(repo.GetType(), dir);
6265

6366
Assert.True(File.Exists(path));
6467
}

0 commit comments

Comments
 (0)