public void Exists() { IDirectoryAdapter d = new DirectoryAdapter(new MapPathImpl(), false, null); var path = Path.GetPathWithoutLastBit(d.MapPath("~/../../DirectoryAdapter_NonTransactionalBehaviour.cs")); // get directory instead Assert.That(d.Exists(path)); }
public void IsInAllowedDir_ReturnsFalseIfConstaint_AndOutside() { var d = new DirectoryAdapter(new MapPathImpl(), true, _CurrDir); Assert.IsFalse(d.IsInAllowedDir("\\")); Assert.IsFalse(d.IsInAllowedDir("\\\\?\\C:\\")); Assert.IsFalse(d.IsInAllowedDir(@"\\.\dev0")); Assert.IsFalse(d.IsInAllowedDir(@"\\?\UNC\/")); }
public void IsInAllowedDir_ReturnsTrueForInside() { var d = new DirectoryAdapter(new MapPathImpl(), true, _CurrDir); Assert.IsTrue(d.IsInAllowedDir(_CurrDir)); Assert.IsTrue(d.IsInAllowedDir(_CurrDir.Combine("hej/something/test"))); Assert.IsTrue(d.IsInAllowedDir(_CurrDir.Combine("hej"))); Assert.IsTrue(d.IsInAllowedDir(_CurrDir.Combine("hej.txt"))); Assert.IsTrue(d.IsInAllowedDir("hej"), "It should return true for relative paths."); Assert.IsTrue(d.IsInAllowedDir("hej.txt"), "It should return true for relative paths"); }
private void RegisterAdapters() { var directoryAdapter = new DirectoryAdapter( Kernel.Resolve<IMapPath>(), !_AllowAccessOutsideRootFolder, RootFolder); Kernel.Register(Component.For<IDirectoryAdapter>().Named("directory.adapter").Instance(directoryAdapter)); var fileAdapter = new FileAdapter( !_AllowAccessOutsideRootFolder, RootFolder); Kernel.Register(Component.For<IFileAdapter>().Named("file.adapter").Instance(fileAdapter)); if (Kernel.HasComponent(typeof(ITransactionManager))) fileAdapter.TxManager = directoryAdapter.TxManager = Kernel.Resolve<ITransactionManager>(); else Kernel.ComponentRegistered += Kernel_ComponentRegistered; }
public void DefaultSettings() { var adapter = new DirectoryAdapter(new MapPathImpl(), false, null); Assert.That(adapter.UseTransactions); Assert.That(adapter.OnlyJoinExisting, Is.False); }
public void IsInAllowedDirReturnsTrueIfNoConstraint() { var ad = new DirectoryAdapter(new MapPathImpl(), false, null); Assert.IsTrue(ad.IsInAllowedDir("\\")); }