2019-11-08 23:38:06 +00:00
using System ;
using Microsoft.VisualStudio.TestTools.UnitTesting ;
using Storj ;
namespace StorjTests
{
[TestClass]
public class ValidateStorageTests
{
private const string StorageDir = "X:\\storage" ;
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The value cannot be empty.")]
public void NullStorage ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( null , StorageDir ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The value cannot be empty.")]
public void EmptyStorage ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "" , StorageDir ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "'some random text' is not a valid number.")]
public void InvalidNumber ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "some random text" , StorageDir ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The allocated disk space cannot be less than 0.5 TB.")]
public void TooSmall ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "0.41" , StorageDir ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "10000000 TB is too large value for allocated storage.")]
public void TooLarge ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "10000000" , StorageDir ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The storage directory cannot be empty")]
public void NullStorageDir ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "3.14" , null ) ;
2019-11-08 23:38:06 +00:00
}
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The storage directory cannot be empty")]
public void EmptyStorageDir ( )
{
2019-11-14 12:02:03 +00:00
new CustomActionRunner ( ) . ValidateStorage ( "3.14" , "" ) ;
2019-11-08 23:38:06 +00:00
}
2019-11-14 12:02:03 +00:00
[TestMethod]
[ExpectedExceptionWithMessage(typeof(ArgumentException), "The disk size (0.2 TB) on the selected drive X:\\ is less than the allocated disk space plus the 10% overhead (3.45 TB total).")]
public void NotEnoughSpace ( )
{
var fs = MockHelpers . MockFileSystemTotalSize ( 200 * CustomActionRunner . GB ) ;
new CustomActionRunner ( fs ) . ValidateStorage ( "3.14" , StorageDir ) ;
}
[TestMethod]
public void ValidStorage ( )
{
var fs = MockHelpers . MockFileSystemTotalSize ( 4 * CustomActionRunner . TB ) ;
new CustomActionRunner ( fs ) . ValidateStorage ( "3.14" , StorageDir ) ;
}
2019-11-08 23:38:06 +00:00
}
}