FileProcessOtherTest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using MyClasses;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MyClassesTest
  10. {
  11. [TestClass]
  12. public class FileProcessOtherTest : TestBase
  13. {
  14. #region Class Initialize and Cleanup Method
  15. [ClassInitialize]
  16. public static void InitializeClass(TestContext tc)
  17. {
  18. tc.WriteLine("In ClassInitialize() method");
  19. }
  20. [ClassCleanup]
  21. public static void CleanUpClass()
  22. {
  23. }
  24. #endregion
  25. #region TestInitialize Method
  26. [TestInitialize]
  27. public void InitializeMethod()
  28. {
  29. TestContext.WriteLine("In TestInitialize() method");
  30. WriteDescription(this.GetType()); // <-- See TestBase
  31. if (TestContext.TestName.StartsWith("FileNameDoesExist"))
  32. {
  33. SetGoodFileName();
  34. if (!string.IsNullOrEmpty(_goodFileName))
  35. {
  36. TestContext.WriteLine("Creating file: " + _goodFileName);
  37. // Create the 'Good' file
  38. File.AppendAllText(_goodFileName, "Some Text");
  39. }
  40. }
  41. }
  42. #endregion
  43. #region TestCleanUp Method
  44. [TestCleanup]
  45. public void CleanUpMethod()
  46. {
  47. TestContext.WriteLine("In TestCleanup() method");
  48. if (TestContext.TestName.StartsWith("FileNameDoesExist"))
  49. {
  50. // Delete File
  51. if (File.Exists(_goodFileName))
  52. {
  53. TestContext.WriteLine("Deleting file: " + _goodFileName);
  54. File.Delete(_goodFileName);
  55. }
  56. }
  57. }
  58. #endregion
  59. [TestMethod]
  60. public void AreSameTest()
  61. {
  62. FileProcess x = new FileProcess();
  63. FileProcess y = new FileProcess();
  64. Assert.AreNotSame(x, y);
  65. }
  66. [TestMethod]
  67. public void AreEqualTest()
  68. {
  69. string str1 = "Paul";
  70. string str2 = "paul";
  71. Assert.AreEqual(str1, str2, true);
  72. }
  73. [TestMethod]
  74. public void AreNotEqualTest()
  75. {
  76. string str1 = "Paul";
  77. string str2 = "John";
  78. Assert.AreNotEqual(str1, str2);
  79. }
  80. //[TestMethod]
  81. public void FileNameDoesExistsSimpleMessage()
  82. {
  83. FileProcess fp = new FileProcess();
  84. bool fromCall;
  85. fromCall = fp.FileExists(_goodFileName);
  86. Assert.IsFalse(fromCall,
  87. "File {0} Does Not Exist.", _goodFileName);
  88. }
  89. }
  90. }