Beispiel #1
0
        public void Local2LocalWithAbsoluteUri()
        {
            var locationFactory = new LocationFactoryUnc2unc ();
            var copier = new Copier { LocationFactory = locationFactory };

            var source = new UncLocation { ItemUri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), @"TestSet\github.jpg")) };
            var destination = new UncLocation { ItemUri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), @"TestSet\github-copy.jpg")) };

            var done = copier.Copy (source, destination, ReplaceMode.Ignore);

            if (done) {
                Assert.IsTrue (File.Exists (destination.ItemUri.LocalPath),
                              "File destination.ItemUri.LocalPath shall exist.");

                var sourceSize = locationFactory.GetSourceManager ().GetSize (source);
                var destinationSize = locationFactory.GetDestinationManager ().GetSize (destination);
                Assert.AreEqual (sourceSize, destinationSize, "File length shall be " + sourceSize + " bytes.");

                locationFactory.GetDestinationManager ().Delete (destination);
            }
        }
Beispiel #2
0
 public void GetFileDownload()
 {
     _mre = new ManualResetEventSlim (false);
     var location = new UncLocation
     {
         ItemUri = new Uri(@"c:\test.pdf"),
     };
     var locationManager = new UncManager (null);
     int bytesRead = 0;
     using (var sw = new BinaryWriter(File.Create(@"c:\test2.pdf"))) {
         locationManager.BeginRetreive (location, buffer =>
         {
             Debug.Assert (sw != null, "sw != null");
             sw.Write (buffer);
             bytesRead += buffer.Length;
         }, () => _mre.Set ());
         _mre.Wait ();
         sw.Flush ();
         sw.Close ();
     }
     Assert.AreEqual (129781, bytesRead);
 }
Beispiel #3
0
        public void Local2LocalWithRelativeUri()
        {
            var locationFactory = new LocationFactoryUnc2unc ();
            var copier = new Copier { LocationFactory = locationFactory };

            var source = new UncLocation { ItemUri = new Uri(@"TestSet\github.jpg", UriKind.Relative) };
            var destination = new UncLocation { ItemUri = new Uri(@"TestSet\github-copy.jpg", UriKind.Relative) };

            var done = copier.Copy (source, destination, ReplaceMode.Ignore);

            Assert.IsTrue (done, "Copy must return true.");
            if (done) {
                var path = destination.ItemUri.IsAbsoluteUri ? destination.ItemUri.LocalPath : destination.ItemUri.ToString ();
                Assert.IsTrue (File.Exists (path),
                              "File " + path + " shall exist.");

                var sourceSize = locationFactory.GetSourceManager ().GetSize (source);
                var destinationSize = locationFactory.GetDestinationManager ().GetSize (destination);
                Assert.AreEqual (sourceSize, destinationSize, "File length shall be " + sourceSize + " bytes.");

                locationFactory.GetDestinationManager ().Delete (destination);
            }
        }
Beispiel #4
0
 public AuthenticationForm(UncLocation host)
 {
     InitializeComponent();
     DestHost = host ?? new UncLocation();
     LoadUncLocation();
 }
Beispiel #5
0
 public AuthenticationForm()
 {
     InitializeComponent();
     DestHost = new UncLocation();
 }