Skip to content

Commit

Permalink
#1833 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jan 21, 2025
1 parent d7addc8 commit 5c48602
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions starsky/starskytest/FakeCreateAn/CreateAnImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ public class CreateAnImage
( Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) +
Path.DirectorySeparatorChar ).Replace("./", string.Empty) + FileNamePrivate;

/// <summary>
/// Size in bytes of the image
/// </summary>
public const int Size = 9998;

/// <summary>
/// Use abstractions instead of a System.IO dependency
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using starsky.foundation.platform.Models;
using starsky.foundation.storage.Helpers;
using starsky.foundation.storage.Storage;
using starskytest.FakeCreateAn;
using starskytest.FakeMocks;
Expand Down Expand Up @@ -55,6 +56,32 @@ public void FileMove_Test()
Assert.IsNotNull(createAnImage);
}

[TestMethod]
public void FileMove_NotFound()
{
Assert.IsFalse(_thumbnailStorage.FileMove("not-found",
"StorageThumbnailFilesystemTest_FileMove.jpg"));
}

[TestMethod]
public async Task FileMove_SkipIfAlreadyExists()
{
var createAnImage = new CreateAnImage();

// first copy for parallel test
_thumbnailStorage.FileCopy(_fileName, "already_exists_file.jpg");
await _thumbnailStorage.WriteStreamAsync(StringToStreamHelper.StringToStream("1"),
"before_test_thumbnail");

_thumbnailStorage.FileMove("before_test_thumbnail", "already_exists_file.jpg");

Assert.AreEqual(CreateAnImage.Size, _thumbnailStorage.Info("already_exists_file").Size);

File.Delete(Path.Combine(createAnImage.BasePath,
"already_exists_file.jpg"));
_thumbnailStorage.FileDelete("before_test_thumbnail");
}

[TestMethod]
public void FileCopy_success()
{
Expand Down Expand Up @@ -242,4 +269,10 @@ public void WriteStreamOpenOrCreate()
Assert.ThrowsException<NotSupportedException>(() =>
_thumbnailStorage.WriteStreamOpenOrCreate(Stream.Null, "not-found"));
}

[TestMethod]
public void Info()
{
Assert.AreEqual(CreateAnImage.Size, _thumbnailStorage.Info(_fileName).Size);
}
}

0 comments on commit 5c48602

Please sign in to comment.