Exemple #1
0
 public void Constructor_PreviousTransactionIdFileExists_ReturnsFoundTransactionId()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         var bundleHelper  = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         var bundleHelper2 = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         Assert.That(bundleHelper.TransactionId, Is.EqualTo(bundleHelper2.TransactionId));
     }
 }
 public void Constructor_PreviousTransactionIdFileExists_ReturnsFoundTransactionId()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         var bundleHelper = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         var bundleHelper2 = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         Assert.That(bundleHelper.TransactionId, Is.EqualTo(bundleHelper2.TransactionId));
     }
 }
 public void Constructor_PreviousTransactionIdFileNotExists_GetNewId()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         string idFilePath = Path.Combine(e.DataFolderPath, "abcde123.transid");
         var bundleHelper = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         File.Delete(idFilePath);
         var bundleHelper2 = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         Assert.That(bundleHelper.TransactionId, Is.Not.EqualTo(bundleHelper2.TransactionId));
     }
 }
Exemple #4
0
 public void Constructor_PreviousTransactionIdFileNotExists_GetNewId()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         string idFilePath   = Path.Combine(e.DataFolderPath, "abcde123.transid");
         var    bundleHelper = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         File.Delete(idFilePath);
         var bundleHelper2 = new SimpleStorageManager(e.BaseFolder.Path, "abcde123");
         Assert.That(bundleHelper.TransactionId, Is.Not.EqualTo(bundleHelper2.TransactionId));
     }
 }
        public void Constructor_ExpiredData_DataIsRemoved()
        {
            using (var e = new BundleStorageEnvForTest())
            {
                string expiredFile = Path.Combine(e.DataFolderPath, "123.transid");
                var expiredTime = DateTime.Now;
                expiredTime = expiredTime.AddHours(-50);
                Directory.CreateDirectory(e.DataFolderPath);

                using (var fs = File.Create(expiredFile)) {}
                File.SetLastWriteTime(expiredFile, expiredTime);

                Assert.That(File.Exists(expiredFile), Is.True);
                var sm = new SimpleStorageManager(e.BaseFolder.Path, "abc");
                Assert.That(File.Exists(expiredFile), Is.False);
            }
        }
Exemple #6
0
        public void Constructor_ExpiredData_DataIsRemoved()
        {
            using (var e = new BundleStorageEnvForTest())
            {
                string expiredFile = Path.Combine(e.DataFolderPath, "123.transid");
                var    expiredTime = DateTime.Now;
                expiredTime = expiredTime.AddHours(-50);
                Directory.CreateDirectory(e.DataFolderPath);

                using (var fs = File.Create(expiredFile)) {}
                File.SetLastWriteTime(expiredFile, expiredTime);

                Assert.That(File.Exists(expiredFile), Is.True);
                var sm = new SimpleStorageManager(e.BaseFolder.Path, "abc");
                Assert.That(File.Exists(expiredFile), Is.False);
            }
        }
 public void Constructor_MultipleInstances_ManagesMultipleInstancesOk()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         var pull1a = new SimpleStorageManager(e.BaseFolder.Path, "number1");
         var pull2a = new SimpleStorageManager(e.BaseFolder.Path, "number2");
         var pull3a = new SimpleStorageManager(e.BaseFolder.Path, "number3");
         var pull4a = new SimpleStorageManager(e.BaseFolder.Path, "number4");
         var pull1b = new SimpleStorageManager(e.BaseFolder.Path, "number1");
         var pull2b = new SimpleStorageManager(e.BaseFolder.Path, "number2");
         var pull3b = new SimpleStorageManager(e.BaseFolder.Path, "number3");
         var pull4b = new SimpleStorageManager(e.BaseFolder.Path, "number4");
         Assert.That(pull1a.TransactionId, Is.EqualTo(pull1b.TransactionId));
         Assert.That(pull2a.TransactionId, Is.EqualTo(pull2b.TransactionId));
         Assert.That(pull3a.TransactionId, Is.EqualTo(pull3b.TransactionId));
         Assert.That(pull4a.TransactionId, Is.EqualTo(pull4b.TransactionId));
     }
 }
Exemple #8
0
 public void Constructor_MultipleInstances_ManagesMultipleInstancesOk()
 {
     using (var e = new BundleStorageEnvForTest())
     {
         var pull1a = new SimpleStorageManager(e.BaseFolder.Path, "number1");
         var pull2a = new SimpleStorageManager(e.BaseFolder.Path, "number2");
         var pull3a = new SimpleStorageManager(e.BaseFolder.Path, "number3");
         var pull4a = new SimpleStorageManager(e.BaseFolder.Path, "number4");
         var pull1b = new SimpleStorageManager(e.BaseFolder.Path, "number1");
         var pull2b = new SimpleStorageManager(e.BaseFolder.Path, "number2");
         var pull3b = new SimpleStorageManager(e.BaseFolder.Path, "number3");
         var pull4b = new SimpleStorageManager(e.BaseFolder.Path, "number4");
         Assert.That(pull1a.TransactionId, Is.EqualTo(pull1b.TransactionId));
         Assert.That(pull2a.TransactionId, Is.EqualTo(pull2b.TransactionId));
         Assert.That(pull3a.TransactionId, Is.EqualTo(pull3b.TransactionId));
         Assert.That(pull4a.TransactionId, Is.EqualTo(pull4b.TransactionId));
     }
 }