Example #1
0
        public void Can_Get_Storage_Info()
        {
            // Arrange
            string currentDir = GetCurrentDir();

            var partitionId    = Guid.NewGuid();
            var cabinetStorage = new PhysicalFileStorageProvider(currentDir, partitionId);

            var cabinet = new Cabinet(cabinetStorage);
            var fileDir = "/foo/bar/";

            cabinet.Storage.CreateFile(new StringFileInfo("super content", "baz.txt"), fileDir);

            var storageInfo = cabinet.StorageInfo;
            var size        = storageInfo.CalculateUsedStorageSize();

            // add another file
            cabinet.Storage.CreateFile(new StringFileInfo("super content", "bat.txt"), fileDir);

            // get size
            var newSize = storageInfo.CalculateUsedStorageSize();

            Assert.Equal(size * 2, newSize);
            var readable = StorageInfo.GetBytesReadable(newSize);
        }