public void Construct_NullConfigurationPath() { var configuration = new FileBlobStorageConfiguration(); this.Invoking(_ => new FileBlobStorage(configuration)) .Should().Throw <ArgumentNullException>(); }
/// <summary> /// Creates a new <see cref="FileBlobStorage"/> instance with the /// specified configuration. /// </summary> /// <param name="configuration">The configuration to use.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="configuration"/> is <c>null</c>. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="configuration"/> is invalid. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="configuration"/> is invalid. /// </exception> public FileBlobStorage(FileBlobStorageConfiguration configuration) : base(configuration) { if (configuration.Path == null) { throw new ArgumentNullException("configuration.Path"); } if (configuration.Path.Length == 0) { throw new ArgumentException("Value cannot be empty.", "configuration.Path"); } if (configuration.ReadBufferSize < 1) { throw new ArgumentOutOfRangeException("configuration.ReadBufferSize"); } if (configuration.WriteBufferSize < 1) { throw new ArgumentOutOfRangeException("configuration.WriteBufferSize"); } _basePath = FileSystem.CreateDirectory(configuration.Path); if (_basePath[_basePath.Length - 1] != Path.DirectorySeparatorChar) { _basePath += Path.DirectorySeparatorChar; } _baseUri = new Uri(_basePath); _readBufferSize = configuration.ReadBufferSize ?? DefaultBufferSize; _writeBufferSize = configuration.WriteBufferSize ?? DefaultBufferSize; //Log.Information("Using file-based blob storage at '{0}'.", _basePath); }
public void Construct_InvalidConfigurationPath() { var configuration = new FileBlobStorageConfiguration { Path = "<*> \0 not a valid path \0 <*>" }; this.Invoking(c => new FileBlobStorage(configuration)) .Should().Throw <Exception>(); }
public void Construct_EmptyConfigurationPath() { var configuration = new FileBlobStorageConfiguration { Path = string.Empty }; this.Invoking(c => new FileBlobStorage(configuration)) .Should().Throw <ArgumentException>(); }
public void Construct_ConfigurationWriteBufferSizeOutOfRange() { var configuration = new FileBlobStorageConfiguration { Path = Configuration.Path, WriteBufferSize = -1, }; this.Invoking(c => new FileBlobStorage(configuration)) .Should().Throw <ArgumentOutOfRangeException>(); }
public void SetUp() { var context = TestContext.CurrentContext; var path = Path.Combine( context.WorkDirectory, "Blobs", context.Test.MethodName ); Configuration = new FileBlobStorageConfiguration { Path = path, ReadBufferSize = 8192, WriteBufferSize = 4096, }; FileSystem = new Mock <FileSystem> { CallBase = true }; }