mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
// ==========================================================================
|
|
// FolderAssetStoreTests.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.IO;
|
|
using Moq;
|
|
using Squidex.Infrastructure.Log;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Infrastructure.Assets
|
|
{
|
|
public class FolderAssetStoreTests : AssetStoreTests<FolderAssetStore>
|
|
{
|
|
private readonly string testFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
|
|
|
public override FolderAssetStore CreateStore()
|
|
{
|
|
return new FolderAssetStore(testFolder, new Mock<ISemanticLog>().Object);
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
if (Directory.Exists(testFolder))
|
|
{
|
|
Directory.Delete(testFolder, true);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_throw_when_creating_directory_failed()
|
|
{
|
|
Assert.Throws<ConfigurationException>(() => new FolderAssetStore(CreateInvalidPath(), new Mock<ISemanticLog>().Object).Connect());
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_create_directory_when_connecting()
|
|
{
|
|
Sut.Connect();
|
|
|
|
Assert.True(Directory.Exists(testFolder));
|
|
}
|
|
|
|
private static string CreateInvalidPath()
|
|
{
|
|
var windir = Environment.GetEnvironmentVariable("windir");
|
|
|
|
return !string.IsNullOrWhiteSpace(windir) ? "Z://invalid" : "/proc/invalid";
|
|
}
|
|
}
|
|
}
|
|
|