public void ItemsPerFileTest()
        {
            const string topFolderName = "ItemsPerFileTest";

            IFolder topFolder = CreateNewTestFolder(topFolderName);

            var targetFolder = topFolder.GetDescendant("Intermediate/Target", true);

            Assert.AreEqual(0, targetFolder.Properties.DesiredItemsPerFile);

            const int itemsPerFile = 12;

            using (var repo1 = GetStandaloneRepository())
            {
                var topFolderInner = repo1.RootFolder.GetDescendant(topFolder.LogicalPath, false);
                Assume.That(null != topFolderInner);

                topFolderInner.Properties.DesiredItemsPerFile = itemsPerFile;

                Assert.AreEqual(itemsPerFile, topFolderInner.Properties.DesiredItemsPerFile);

                var targetFolderInner = repo1.RootFolder.GetDescendant(targetFolder.LogicalPath, false);
                Assume.That(null != targetFolderInner);

                Assert.AreEqual(itemsPerFile, targetFolderInner.Properties.DesiredItemsPerFile);
            }

            using (var repo1 = GetStandaloneRepository())
            {
                var topFolderInner = repo1.RootFolder.GetDescendant(topFolder.LogicalPath, false);
                Assume.That(null != topFolderInner);


                var targetFolderInner = repo1.RootFolder.GetDescendant(targetFolder.LogicalPath, false);
                Assume.That(null != targetFolderInner);

                Assert.AreEqual(itemsPerFile, targetFolderInner.Properties.DesiredItemsPerFile);

                using (var writer = targetFolderInner.GetWriter())
                {
                    IDataRouter dataRouter = new Mock.NumberedDataRouter(2);
                    writer.DataRouter = dataRouter;
                    writer.AllowSubfoldersCreation = true;

                    IDataItem[] data = RepositoryWriterTest.GetTestData(100, DateTime.Now, 2);

                    for (int n = 0; n < 100; ++n)
                    {
                        writer.Write(data[n]);
                    }
                    //writer.Flush();
                    // flushes data
                    writer.Close();

                    var enm = targetFolderInner.SubFolders.GetEnumerator();
                    Assert.IsTrue(enm.MoveNext());
                    var dataFile = ((IFolder)enm.Current).RootDataFolder.FindFirstDataFile(false);
                    Assert.IsNotNull(dataFile);


                    using (var reader = targetFolderInner.GetReader(DateTime.MinValue, true))
                    {
                        IDataItem[] dataRead = new IDataItem[data.Length];
                        int         n        = 0;
                        while (reader.HasData)
                        {
                            dataRead[n] = reader.Read().DataItem;
                            Assert.AreEqual(data[n], dataRead[n]);
                            ++n;
                        }
                        Assert.AreEqual(data.Length, n);
                    }
                }
            }
        }
        public void CoderEncryptorConfigTest()
        {
            const string topFolderName = "CoderEncryptorConfigTest";

            IFolder topFolder = (IFolder)FixtureRootRepoFolder.GetSubFolder(topFolderName);

            if (topFolder != null)
            {
                topFolder.Delete(true, true);
            }

            topFolder = (IFolder)FixtureRootRepoFolder.CreateSubfolder(topFolderName);

            var targetFolder = topFolder.GetDescendant("Intermediate/Target", true);

            Assert.AreEqual(string.Empty, targetFolder.Properties.Encryptor);
            Assert.AreEqual(string.Empty, targetFolder.Properties.Compressor);

            const string coderKey = "my-coder";
            const string encKey   = "my-encryptor";

            using (var repo1 = GetStandaloneRepository())
            {
                var topFolderInner = repo1.RootFolder.GetDescendant(topFolder.LogicalPath, false);
                Assume.That(null != topFolderInner);

                Assert.Throws <ArgumentException>(() => topFolderInner.Properties.Compressor = coderKey);
                Assert.Throws <ArgumentException>(() => topFolderInner.Properties.Encryptor  = encKey);

                repo1.ObjectFactory.AddCompressor(new CoderMock(coderKey), false);
                repo1.ObjectFactory.AddEncryptor(new CoderMock(encKey), false);

                topFolderInner.Properties.Compressor       = coderKey;
                topFolderInner.Properties.Encryptor        = encKey;
                topFolderInner.Properties.EnableEncryption = true;

                Assert.AreEqual(coderKey, topFolderInner.Properties.Compressor);
                Assert.AreEqual(encKey, topFolderInner.Properties.Encryptor);

                var targetFolderInner = repo1.RootFolder.GetDescendant(targetFolder.LogicalPath, false);
                Assume.That(null != targetFolderInner);

                Assert.AreEqual(coderKey, targetFolderInner.Properties.Compressor);
                Assert.AreEqual(encKey, targetFolderInner.Properties.Encryptor);
            }

            using (var repo1 = GetStandaloneRepository())
            {
                var topFolderInner = repo1.RootFolder.GetDescendant(topFolder.LogicalPath, false);
                Assume.That(null != topFolderInner);

                repo1.ObjectFactory.AddCompressor(new CoderMock(coderKey), false);
                repo1.ObjectFactory.AddEncryptor(new CoderMock(encKey), false);

                var targetFolderInner = repo1.RootFolder.GetDescendant(targetFolder.LogicalPath, false);
                Assume.That(null != targetFolderInner);

                Assert.AreEqual(coderKey, targetFolderInner.Properties.Compressor);
                Assert.AreEqual(encKey, targetFolderInner.Properties.Encryptor);

                using (var writer = targetFolderInner.GetWriter())
                {
                    IDataRouter dataRouter = new Mock.NumberedDataRouter(2);
                    writer.DataRouter = dataRouter;
                    writer.AllowSubfoldersCreation = true;

                    IDataItem[] data = RepositoryWriterTest.GetTestData(100, DateTime.Now, 2);

                    for (int n = 0; n < 100; ++n)
                    {
                        writer.Write(data[n]);
                    }
                    //writer.Flush();
                    // flushes data
                    writer.Close();

                    var enm = targetFolderInner.SubFolders.GetEnumerator();
                    Assert.IsTrue(enm.MoveNext());
                    var dataFile = ((IFolder)enm.Current).RootDataFolder.FindFirstDataFile(false);
                    Assert.IsNotNull(dataFile);

                    Assert.IsTrue(dataFile.Path.EndsWith(encKey));

                    using (var reader = targetFolderInner.GetReader(DateTime.MinValue, true))
                    {
                        IDataItem[] dataRead = new IDataItem[data.Length];
                        int         n        = 0;
                        while (reader.HasData)
                        {
                            dataRead[n] = reader.Read().DataItem;
                            Assert.AreEqual(data[n], dataRead[n]);
                            ++n;
                        }
                        Assert.AreEqual(data.Length, n);
                    }
                }
            }
        }