Example #1
0
 public void TearDown()
 {
     _unitUnderTest.Close();
     _unitUnderTest = null;
     if (Directory.Exists(Path.GetDirectoryName(_filename)))
         Directory.Delete(Path.GetDirectoryName(_filename), true);
 }
Example #2
0
 public void SetUp()
 {
     if(!Directory.Exists(Path.GetDirectoryName(_filename)))
         Directory.CreateDirectory(Path.GetDirectoryName(_filename));
     XmlTextWriter tx = new XmlTextWriter(_filename, Encoding.UTF8);
     _unitUnderTest = new EmlWriter(tx);
 }
Example #3
0
        /// <summary>
        /// Creates the eml formatted file.
        /// </summary>
        /// <param name="fileName">The eml formatted file name</param>
        /// <param name="storedList">The list of the stored "EcellObject"</param>
        /// <param name="isProjectSave">whether project is saved.</param>
        public static void Create(string fileName, List<EcellObject> storedList, bool isProjectSave)
        {
            //
            // Checks the old model file.
            //
            if (File.Exists(fileName))
            {
                BackUpModel(fileName);
            }

            // For single model
            if (isProjectSave)
            {
                string dirName = Path.GetDirectoryName(fileName);
                string[] models = Directory.GetFileSystemEntries(
                                        dirName,
                                        Constants.delimiterWildcard + Constants.delimiterPeriod + Constants.xpathEml);
                if (models != null && models.Length > 0)
                {
                    foreach (string model in models)
                    {
                        if (Path.GetFileName(model).IndexOf(Constants.delimiterUnderbar) != 0)
                        {
                            BackUpModel(model);
                        }
                    }
                }
            }

            //
            // Saves the model
            //
            XmlTextWriter m_tx = new XmlTextWriter(fileName, System.Text.Encoding.UTF8);
            try
            {
                m_tx.Formatting = Formatting.Indented;
                m_tx.Indentation = 0;
                EmlWriter ew = new EmlWriter(m_tx);
                ew.WriteStartDocument();
                ew.Write(storedList);
                ew.WriteEndDocument();
            }
            finally
            {
                m_tx.Close();
            }
        }
Example #4
0
 public void TestConstructorEmlWriter()
 {
     _unitUnderTest.Close();
     XmlTextWriter tx = new XmlTextWriter(_filename, Encoding.UTF8);
     EmlWriter testEmlWriter = new EmlWriter(tx);
     Assert.IsNotNull(testEmlWriter, "Constructor of type, EmlWriter failed to create instance.");
     testEmlWriter.Close();
 }