Skip to content

Commit

Permalink
changed property names.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanmark7 committed Oct 4, 2024
1 parent 9400fbc commit 5641fa6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}

public static DataContext Create(string connectionString)
{
return new DataContext(DataContextUtils.Parse<DataContext>(connectionString));
}
//public static DataContext Create(string connectionString)
//{
// return new DataContext(DataContextUtils.Parse<DataContext>(connectionString));
//}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,54 @@
// </copyright>
// ================================================================================

using System.Diagnostics.CodeAnalysis;
using ThingsLibrary.Database.Tests.Integration.Base;
using ThingsLibrary.Testing.Attributes;
using ThingsLibrary.Testing.Environment;

namespace ThingsLibrary.Database.Tests.Integration.SqlServer
{
[TestClassIf, IgnoreIf(nameof(Base.ServerTests.IgnoreTests)), ExcludeFromCodeCoverage]
public class ServerTests
{
#region --- Provider ---
//using System.Diagnostics.CodeAnalysis;
//using ThingsLibrary.Database.Tests.Integration.Base;
//using ThingsLibrary.Testing.Attributes;
//using ThingsLibrary.Testing.Environment;

//namespace ThingsLibrary.Database.Tests.Integration.SqlServer
//{
// [TestClassIf, IgnoreIf(nameof(Base.ServerTests.IgnoreTests)), ExcludeFromCodeCoverage]
// public class ServerTests
// {
// #region --- Provider ---

private static DataContext DB { get; set; }
// private static DataContext DB { get; set; }


// ======================================================================
// Called once before ALL tests
// ======================================================================
[ClassInitialize]
public static async Task ClassInitialize(TestContext testContext)
{
await Base.ServerTests.ClassInitialize(testContext);

//DB = DataContext.Create(TestEnvironment.ConnectionString);
//DB.Database.EnsureDeleted(); //clean up for bad run last time (if exists)
//DB.Database.EnsureCreated();
}

// ======================================================================
// Called once AFTER all tests
// ======================================================================
[ClassCleanup]
public static async Task ClassCleanup()
{
await Base.ServerTests.ClassCleanup();
}
// // ======================================================================
// // Called once before ALL tests
// // ======================================================================
// [ClassInitialize]
// public static async Task ClassInitialize(TestContext testContext)
// {
// await Base.ServerTests.ClassInitialize(testContext);

// //DB = DataContext.Create(TestEnvironment.ConnectionString);
// //DB.Database.EnsureDeleted(); //clean up for bad run last time (if exists)
// //DB.Database.EnsureCreated();
// }

// // ======================================================================
// // Called once AFTER all tests
// // ======================================================================
// [ClassCleanup]
// public static async Task ClassCleanup()
// {
// await Base.ServerTests.ClassCleanup();
// }


#endregion
// #endregion

[TestMethod]
public void Inherited_AddUpdateDelete()
{
var entityTester = new EntityTester<TestData.TestInheritedClass>(DataContext, DataContext.TestInheritedClasses);
// [TestMethod]
// public void Inherited_AddUpdateDelete()
// {
// var entityTester = new EntityTester<TestData.TestInheritedClass>(DataContext, DataContext.TestInheritedClasses);

var expectedData = TestData.TestInheritedClass.GetInherited();
// var expectedData = TestData.TestInheritedClass.GetInherited();

Assert.IsTrue(entityTester.AddUpdateDelete(expectedData));
}
}
}
// Assert.IsTrue(entityTester.AddUpdateDelete(expectedData));
// }
// }
//}
16 changes: 8 additions & 8 deletions Storage/src/ThingsLibrary.Storage.Local/FileStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public FileStore(string storageConnectionString, string bucketName)
this.DataCollection = this.DataContext.GetCollection<FileItem>(bucketName);

// make sure we can do quick lookups
this.DataCollection.EnsureIndex(x => x.FilePath);
this.DataCollection.EnsureIndex(x => x.Path);

// see if we need to populate database
if (!this.IsDatabasePopulated())
Expand Down Expand Up @@ -193,7 +193,7 @@ public IEnumerable<IFileItem> GetFileVersions(string cloudFilePath)

var prefix = $"{Path.GetDirectoryName(cloudFilePath)}/~revisions/{Path.GetFileNameWithoutExtension(cloudFilePath)}~Rev";

return this.DataCollection.Find(x => x.FilePath.StartsWith(prefix));
return this.DataCollection.Find(x => x.Path.StartsWith(prefix));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -235,7 +235,7 @@ public void UploadFile(string localFilePath, string cloudFilePath)
cloudFile = this.GenerateCloudFile(storageFilePath);

//add / update cloud file to database
this.DataCollection.Upsert(new BsonValue(cloudFile.FilePath.ToLower()), cloudFile);
this.DataCollection.Upsert(new BsonValue(cloudFile.Path.ToLower()), cloudFile);
}

/// <inheritdoc/>
Expand All @@ -250,7 +250,7 @@ public void DownloadFile(string cloudFilePath, string localFilePath)
var cloudFile = this.GetCloudFile(cloudFilePath);
if (cloudFile == null) { throw new FileNotFoundException(); }

var storageFilePath = this.GetStorageFilePath(cloudFile.FilePath);
var storageFilePath = this.GetStorageFilePath(cloudFile.Path);

System.IO.File.Copy(storageFilePath, localFilePath, true);
}
Expand All @@ -261,7 +261,7 @@ public void DownloadFile(string cloudFilePath, Stream stream)
var cloudFile = this.GetCloudFile(cloudFilePath);
if (cloudFile == null) { throw new FileNotFoundException(); }

var storageFilePath = this.GetStorageFilePath(cloudFile.FilePath);
var storageFilePath = this.GetStorageFilePath(cloudFile.Path);
if (!System.IO.File.Exists(storageFilePath)) { throw new FileNotFoundException($"File not found at: {storageFilePath}"); }

var buffer = new byte[4096];
Expand Down Expand Up @@ -289,7 +289,7 @@ public void DeleteFile(string cloudFilePath)
}

// delete the file
var storageFilePath = this.GetStorageFilePath(cloudFile.FilePath);
var storageFilePath = this.GetStorageFilePath(cloudFile.Path);

if (System.IO.File.Exists(storageFilePath))
{
Expand Down Expand Up @@ -415,7 +415,7 @@ private void UpdateDatabaseFile(string storageFilePath)
cloudFile = this.GenerateCloudFile(storageFilePath);

//add cloud file to database
this.DataCollection.Upsert(new BsonValue(cloudFile.FilePath.ToLower()), cloudFile);
this.DataCollection.Upsert(new BsonValue(cloudFile.Path.ToLower()), cloudFile);
}

private string GetOrCreateDatabasePath()
Expand Down Expand Up @@ -496,7 +496,7 @@ private string GetOrCreateRevisionsPath(string storageFilePath)
/// <param name="cloudFile">Cloud file we want to create a reivison file of</param>
private void CreateRevisionFile(FileItem cloudFile)
{
var storageFilePath = Path.Combine(this.BucketDirectoryPath, cloudFile.FilePath);
var storageFilePath = Path.Combine(this.BucketDirectoryPath, cloudFile.Path);

var revisionsFolderPath = this.GetOrCreateRevisionsPath(storageFilePath);
var revisionFilePath = Path.Combine(revisionsFolderPath, $"{Path.GetFileNameWithoutExtension(storageFilePath)}~Rev{DateTimeOffset.Now.ToUnixTimeSeconds()}{Path.GetExtension(storageFilePath)}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void TestFile(IFileStore fileStore)
var cloudFile = fileStore.GetFile(cloudFilePath);

Assert.AreEqual(md5, cloudFile.ContentMD5);
Assert.AreEqual(Path.GetFileName(filePath), cloudFile.FileName);
Assert.AreEqual(Path.GetFileName(filePath), cloudFile.Name);

// ======================================================================
// DOWNLOAD FILE
Expand Down Expand Up @@ -144,7 +144,7 @@ public static void TestImageFile(IFileStore fileStore)
var cloudFile = fileStore.GetFile(cloudFilePath);

Assert.AreEqual(md5, cloudFile.ContentMD5);
Assert.AreEqual(Path.GetFileName(filePath), cloudFile.FileName);
Assert.AreEqual(Path.GetFileName(filePath), cloudFile.Name);

// ======================================================================
// DOWNLOAD FILE
Expand Down

0 comments on commit 5641fa6

Please sign in to comment.