Update README.md with project details, features, requirements, architecture, and data management for PLib video library manager.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using PLib.Domain.Videos;
|
||||
using Shouldly;
|
||||
|
||||
namespace PLib.Tests.Domain;
|
||||
|
||||
public sealed class VideoItemTests
|
||||
{
|
||||
private static VideoItem CreateIndexedItem()
|
||||
{
|
||||
var item = new VideoItem(@"C:\videos\clip.mp4", "clip", 1_000, DateTimeOffset.UnixEpoch);
|
||||
item.ApplyTechnicalInfo(new VideoTechnicalInfo(TimeSpan.FromMinutes(3), 1920, 1080, "h264"));
|
||||
item.AttachThumbnail(@"C:\cache\clip.jpg");
|
||||
return item;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_item_is_indexed_only_once_it_has_both_a_duration_and_a_thumbnail()
|
||||
{
|
||||
var item = new VideoItem(@"C:\videos\clip.mp4", "clip", 1_000, DateTimeOffset.UnixEpoch);
|
||||
item.IsIndexed.ShouldBeFalse();
|
||||
|
||||
item.ApplyTechnicalInfo(new VideoTechnicalInfo(TimeSpan.FromMinutes(1), 1280, 720, "h264"));
|
||||
item.IsIndexed.ShouldBeFalse();
|
||||
|
||||
item.AttachThumbnail(@"C:\cache\clip.jpg");
|
||||
item.IsIndexed.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Refreshing_an_unchanged_file_keeps_everything_that_was_derived_from_it()
|
||||
{
|
||||
var item = CreateIndexedItem();
|
||||
|
||||
item.RefreshFileFacts(1_000, DateTimeOffset.UnixEpoch);
|
||||
|
||||
item.IsIndexed.ShouldBeTrue();
|
||||
item.ThumbnailPath.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Refreshing_a_changed_file_invalidates_the_metadata_and_the_thumbnail()
|
||||
{
|
||||
var item = CreateIndexedItem();
|
||||
|
||||
item.RefreshFileFacts(2_000, DateTimeOffset.UnixEpoch.AddDays(1));
|
||||
|
||||
item.SizeInBytes.ShouldBe(2_000);
|
||||
item.Duration.ShouldBeNull();
|
||||
item.ThumbnailPath.ShouldBeNull();
|
||||
item.IsIndexed.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("", "title")]
|
||||
[InlineData(" ", "title")]
|
||||
[InlineData(@"C:\videos\clip.mp4", "")]
|
||||
public void An_item_cannot_be_created_without_a_path_and_a_title(string path, string title) =>
|
||||
Should.Throw<ArgumentException>(() => new VideoItem(path, title, 1, DateTimeOffset.UnixEpoch));
|
||||
|
||||
[Fact]
|
||||
public void An_item_cannot_have_a_negative_size() =>
|
||||
Should.Throw<ArgumentOutOfRangeException>(
|
||||
() => new VideoItem(@"C:\videos\clip.mp4", "clip", -1, DateTimeOffset.UnixEpoch));
|
||||
}
|
||||
Reference in New Issue
Block a user