Exemple #1
0
        public void GetCloudFileTest()
        {
            var share = FileShareManager.GetFileShare(ConfigurationManager.AppSettings["ClientFileShare"]);
            var file  = FileManager.GetCloudFile(TestDirectory, TestFile);

            Console.WriteLine(file.DownloadText());
        }
Exemple #2
0
        public void UpdateFileShareQuotaTest()
        {
            var share = FileShareManager.GetFileShare(ConfigurationManager.AppSettings["ClientFileShare"]);

            try
            {
                // Set property in memory. Quota has a minimum of 1.
                share.Properties.Quota = 1;

                // Set property must be called to ensure that FetchAttributes doesn't retrieve old data.
                share.Properties.Quota = 1;
                share.SetProperties();
                share.FetchAttributes();
                Assert.IsTrue(share.Properties.Quota < DefaultQuota);

                // Get current stats.
                var stats = share.GetStats();

                // Set to greater than the current usage.
                share.Properties.Quota = 10 + stats.Usage;
                share.SetProperties();
                share.FetchAttributes();
                Assert.IsTrue(share.Properties.Quota > 0);

                // Restore to original default setting.
                share.Properties.Quota = DefaultQuota;
                share.SetProperties();
                share.FetchAttributes();
                Assert.AreEqual(DefaultQuota, share.Properties.Quota);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public void CheckFileShareCurrentUsageTest()
        {
            var share = FileShareManager.GetFileShare(ConfigurationManager.AppSettings["ClientFileShare"]);
            var stats = share.GetStats();

            // Check the current usage stats for the share.
            //throw new Exception(String.Format("Current share usage: {0} GB", stats.Usage.ToString()));

            // Check the current quota for the share. Fetch attributes populates the share's properties with up-to-date data.
            //throw new Exception(String.Format("Current share quota: {0} GB", share.Properties.Quota));

            Assert.AreEqual(DefaultQuota, share.Properties.Quota);

            // Check that at least 10 GB of usage are still available before exceeding quota.
            Assert.IsTrue(share.Properties.Quota > stats.Usage + 10);
        }
Exemple #4
0
        public bool Start()
        {
            var uri = new Uri[1];

            if (!string.IsNullOrEmpty(Uri) && Port > 0)
            {
                var address = $"net.tcp://{Uri}:{Port}/Fileshare";
                uri[0] = new Uri(address);
                IFileShareService fileShare = new FileShareManager();
                _host = new ServiceHost(fileShare, uri);
                var binding = new NetTcpBinding(SecurityMode.None);
                _host.AddServiceEndpoint(typeof(IFileShareService), binding, "");
                _host.Opened += HostOnOpened;
                _host.Open();
                return(IsStarted);
            }
            return(IsStarted);
        }
Exemple #5
0
        public static void Run()
        {
            var share = FileShareManager.GetFileShare(ConfigurationManager.AppSettings["ClientFileShare"]);

            if (share == null)
            {
                throw new Exception("Couldn't retrieve file share.");
            }

            var file = FileManager.GetFile(share, "11645-TestFile.zip", "Test");

            if (file == null)
            {
                throw new Exception("Couldn't retrieve file.");
            }

            // Write the contents of the file to the console window.
            Console.WriteLine(file.DownloadTextAsync().Result);
            Console.Read();
        }
Exemple #6
0
 public void GetClientFileShareTest()
 {
     Assert.IsNotNull(FileShareManager.GetFileShare(ConfigurationManager.AppSettings["ClientFileShare"]));
 }