Exemple #1
0
        public void Basic()
        {
            FwTempFile orange = new FwTempFile();

            orange.Writer.Write(kcontent);
            CheckAndDispose(orange);
        }
Exemple #2
0
        public void CustomExtension()
        {
            FwTempFile orange = new FwTempFile(".htm");

            orange.Writer.Write(kcontent);
            CheckAndDispose(orange);
        }
Exemple #3
0
        public void CantDelete()
        {
            FwTempFile orange = new FwTempFile();

            orange.Writer.Write(kcontent);
            string       path   = orange.CloseAndGetPath();
            StreamReader reader = File.OpenText(path);

            orange.Dispose();
        }
Exemple #4
0
        public void CreateTempFileAndGetPathTest()
        {
            string sFile = FwTempFile.CreateTempFileAndGetPath("tmp");

            Assert.IsNotNull(sFile);
            Assert.IsTrue(sFile.Length > 0, "Expected temp file name to be non-empty");
            if (File.Exists(sFile))
            {
                File.Delete(sFile);
            }
        }
Exemple #5
0
		public void Detach()
		{
			FwTempFile orange = new FwTempFile();
			orange.Writer.Write(kcontent);
			string path = orange.CloseAndGetPath();
			StreamReader reader = File.OpenText(path);

			orange.Detach();
			// This will close the writer.
			orange.Dispose();

			reader.Close();
			File.Delete(path);
		}
Exemple #6
0
        public void Detach()
        {
            FwTempFile orange = new FwTempFile();

            orange.Writer.Write(kcontent);
            string       path   = orange.CloseAndGetPath();
            StreamReader reader = File.OpenText(path);

            orange.Detach();
            // This will close the writer.
            orange.Dispose();

            reader.Close();
            File.Delete(path);
        }
Exemple #7
0
		/// <summary></summary>
		protected void CheckAndDispose(FwTempFile orange)
		{
			string tempPath = orange.CloseAndGetPath();
			StreamReader reader = null;
			try
			{
				reader = File.OpenText(tempPath);
				string s = reader.ReadToEnd();
				Assert.AreEqual(kcontent, s, "Contents of temp file did not match what I wrote to it.");
			}
			finally
			{
				if (reader != null)
					reader.Close();
				orange.Dispose();
			}
			Assert.IsFalse(File.Exists(tempPath), "Temp file was not deleted.");
		}
Exemple #8
0
        /// <summary></summary>
        protected void CheckAndDispose(FwTempFile orange)
        {
            string       tempPath = orange.CloseAndGetPath();
            StreamReader reader   = null;

            try
            {
                reader = File.OpenText(tempPath);
                string s = reader.ReadToEnd();
                Assert.AreEqual(kcontent, s, "Contents of temp file did not match what I wrote to it.");
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                orange.Dispose();
            }
            Assert.IsFalse(File.Exists(tempPath), "Temp file was not deleted.");
        }
Exemple #9
0
		public void CantDelete()
		{
			FwTempFile orange = new FwTempFile();
			orange.Writer.Write(kcontent);
			string path = orange.CloseAndGetPath();
			StreamReader reader = File.OpenText(path);
			orange.Dispose();
		}
Exemple #10
0
		public void Basic()
		{
			FwTempFile orange = new FwTempFile();
			orange.Writer.Write(kcontent);
			CheckAndDispose(orange);
		}
Exemple #11
0
		public void CustomExtension()
		{
			FwTempFile orange = new FwTempFile(".htm");
			orange.Writer.Write(kcontent);
			CheckAndDispose(orange);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the temp file.
		/// </summary>
		/// <param name="sExtension">The extension.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private string CreateTempFile(string sExtension)
		{
			// FwTempFile has a Dispose method so we have to call it.
			using (FwTempFile tmpFile = new FwTempFile(sExtension))
			{
				string sInput = tmpFile.CloseAndGetPath();
				return sInput;
			}
		}
		private string CreateTempFile(string sExtension)
		{
			FwTempFile tmpFile = new FwTempFile(sExtension);
			string sInput = tmpFile.CloseAndGetPath();
			return sInput;
		}
Exemple #14
0
        /// <summary>
        /// Create a temporary file; close it; and return the path to it.
        /// </summary>
        /// <param name="extension">File extension to use for the temporary file</param>
        /// <returns>full path to the newly created temporary file</returns>
        public static string CreateTempFileAndGetPath(string extension)
        {
            FwTempFile tmpFile = new FwTempFile(extension);

            return(tmpFile.CloseAndGetPath());
        }
Exemple #15
0
		/// <summary>
		/// Create a temporary file; close it; and return the path to it.
		/// </summary>
		/// <param name="extension">File extension to use for the temporary file</param>
		/// <returns>full path to the newly created temporary file</returns>
		public static string CreateTempFileAndGetPath(string extension)
		{
			FwTempFile tmpFile = new FwTempFile(extension);
			return tmpFile.CloseAndGetPath();
		}