| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using MyClasses;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MyClassesTest
- {
- [TestClass]
- public class FileProcessOtherTest : TestBase
- {
- #region Class Initialize and Cleanup Method
- [ClassInitialize]
- public static void InitializeClass(TestContext tc)
- {
- tc.WriteLine("In ClassInitialize() method");
- }
- [ClassCleanup]
- public static void CleanUpClass()
- {
- }
- #endregion
- #region TestInitialize Method
- [TestInitialize]
- public void InitializeMethod()
- {
- TestContext.WriteLine("In TestInitialize() method");
- WriteDescription(this.GetType()); // <-- See TestBase
- if (TestContext.TestName.StartsWith("FileNameDoesExist"))
- {
- SetGoodFileName();
- if (!string.IsNullOrEmpty(_goodFileName))
- {
- TestContext.WriteLine("Creating file: " + _goodFileName);
- // Create the 'Good' file
- File.AppendAllText(_goodFileName, "Some Text");
- }
- }
- }
- #endregion
-
- #region TestCleanUp Method
- [TestCleanup]
- public void CleanUpMethod()
- {
- TestContext.WriteLine("In TestCleanup() method");
- if (TestContext.TestName.StartsWith("FileNameDoesExist"))
- {
- // Delete File
- if (File.Exists(_goodFileName))
- {
- TestContext.WriteLine("Deleting file: " + _goodFileName);
- File.Delete(_goodFileName);
- }
- }
- }
- #endregion
- [TestMethod]
- public void AreSameTest()
- {
- FileProcess x = new FileProcess();
- FileProcess y = new FileProcess();
- Assert.AreNotSame(x, y);
- }
- [TestMethod]
- public void AreEqualTest()
- {
- string str1 = "Paul";
- string str2 = "paul";
- Assert.AreEqual(str1, str2, true);
- }
- [TestMethod]
- public void AreNotEqualTest()
- {
- string str1 = "Paul";
- string str2 = "John";
- Assert.AreNotEqual(str1, str2);
- }
- //[TestMethod]
- public void FileNameDoesExistsSimpleMessage()
- {
- FileProcess fp = new FileProcess();
- bool fromCall;
- fromCall = fp.FileExists(_goodFileName);
- Assert.IsFalse(fromCall,
- "File {0} Does Not Exist.", _goodFileName);
- }
- }
- }
|