Example #1
0
        public void SetUp()
        {
            directoryCache = new Mock <IDirectoryCache>();

            directory = new Mock <IDirectory>();
            directory.SetupGet(x => x.BlockId).Returns(321);
            directoryCache.Setup(x => x.ReadDirectory(321)).Returns(directory.Object);

            fileParameters =
                Mock.Of <IFileParameters>(x => x.BlockId == 123 && x.ParentDirectoryBlockId == 321 && x.Size == 511);

            indexBlockProvider        = new Mock <IIndexBlockProvider>();
            indexBlockProviderFactory = new Mock <IFactory <IIndexBlockProvider, int, ICommonAccessParameters> >();
            indexBlockProviderFactory.Setup(x => x.Create(123, It.IsAny <ICommonAccessParameters>()))
            .Returns(indexBlockProvider.Object);

            index = new Mock <IIndex <byte> >();
            index.SetupGet(x => x.BlockId).Returns(123);

            indexFactory = new Mock <IFactory <IIndex <byte>, IIndexBlockProvider, ICommonAccessParameters> >();
            indexFactory.Setup(x => x.Create(It.IsAny <IIndexBlockProvider>(), It.IsAny <ICommonAccessParameters>()))
            .Returns(index.Object);

            blockStream        = new Mock <IBlockStream <byte> >();
            blockStreamFactory = new Mock <IFactory <IBlockStream <byte>, IBlockProvider <byte> > >();
            blockStreamFactory.Setup(x => x.Create(It.IsAny <IBlockProvider <byte> >())).Returns(blockStream.Object);
        }
Example #2
0
File: File.cs Project: ilf80/FS
        public File(
            IDirectoryCache directoryCache,
            IFileParameters fileParameters,
            IFactory <IIndexBlockProvider, int, ICommonAccessParameters> indexBlockProviderFactory,
            IFactory <IIndex <byte>, IIndexBlockProvider, ICommonAccessParameters> indexFactory,
            IFactory <IBlockStream <byte>, IBlockProvider <byte> > blockStreamFactory)
        {
            if (fileParameters == null)
            {
                throw new ArgumentNullException(nameof(fileParameters));
            }

            if (indexBlockProviderFactory == null)
            {
                throw new ArgumentNullException(nameof(indexBlockProviderFactory));
            }

            if (blockStreamFactory == null)
            {
                throw new ArgumentNullException(nameof(blockStreamFactory));
            }

            this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache));

            directoryBlockId = fileParameters.ParentDirectoryBlockId;
            Size             = fileParameters.Size;

            var provider = indexBlockProviderFactory.Create(fileParameters.BlockId, this.directoryCache);

            index       = indexFactory.Create(provider, directoryCache);
            blockStream = blockStreamFactory.Create(index);
        }
Example #3
0
 public void SetUp()
 {
     directoryCache            = new Mock <IDirectoryCache>();
     indexBlockProvider        = new Mock <IIndexBlockProvider>();
     indexBlockProviderFactory = new Mock <IFactory <IIndexBlockProvider, int, ICommonAccessParameters> >();
     indexBlockProviderFactory.Setup(x => x.Create(It.IsAny <int>(), It.IsAny <ICommonAccessParameters>()))
     .Returns(indexBlockProvider.Object);
     index        = new Mock <IIndex <byte> >();
     indexFactory = new Mock <IFactory <IIndex <byte>, IIndexBlockProvider, ICommonAccessParameters> >();
     indexFactory.Setup(x => x.Create(It.IsAny <IIndexBlockProvider>(), It.IsAny <ICommonAccessParameters>()))
     .Returns(index.Object);
     fileParameters = Mock.Of <IFileParameters>(x => x.BlockId == 123 && x.ParentDirectoryBlockId == 321);
 }
Example #4
0
        public DeletionFile(
            IDirectoryCache directoryCache,
            IFactory <IIndexBlockProvider, int, ICommonAccessParameters> indexBlockProviderFactory,
            IFactory <IIndex <byte>, IIndexBlockProvider, ICommonAccessParameters> indexFactory,
            IFileParameters fileParameters)
        {
            if (indexBlockProviderFactory == null)
            {
                throw new ArgumentNullException(nameof(indexBlockProviderFactory));
            }

            if (indexFactory == null)
            {
                throw new ArgumentNullException(nameof(indexFactory));
            }

            this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache));
            this.fileParameters = fileParameters ?? throw new ArgumentNullException(nameof(fileParameters));

            var provider = indexBlockProviderFactory.Create(fileParameters.BlockId, directoryCache);

            index = indexFactory.Create(provider, directoryCache);
        }
 public AmazonApplication(IAmazonRequest amazonRequest, IFileParameters fileParameters)
 {
     amazonFactory = new AmazonFactory(amazonRequest);
     this.fileParameters = fileParameters;
 }