No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

SolutionServiceTest.cs 5.4KB

hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using SIE.IVSDK.Services;
  3. using SIE.VSDK.Exceptions.DirectoryDestination;
  4. using SIE.VSDK.Exceptions.Solution;
  5. using SIE.VSDK.Services;
  6. using System;
  7. using System.IO;
  8. namespace SIE.VSDK.Test
  9. {
  10. [TestClass]
  11. public class SolutionServiceTest
  12. {
  13. private readonly ISolutionService _solutionService;
  14. private string dirTest = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).FullName).FullName).FullName).FullName;
  15. public SolutionServiceTest()
  16. {
  17. IPathService pathService = new PathService();
  18. _solutionService = new SolutionService(pathService);
  19. }
  20. [TestMethod]
  21. [ExpectedException(typeof(SolutionPathIsNullException), "Le chemin de la solution passé en premier paramètre est null !")]
  22. public void TestSolutionPathIsNullError01()
  23. {
  24. _solutionService.CreateProjectTemplatesFromSolution(null, "","");
  25. }
  26. [TestMethod]
  27. [ExpectedException(typeof(SolutionPathIsEmptyException), "Le chemin de la solution passé en premier paramètre eqt vide !")]
  28. public void TestSolutionPathIsNotAFileError02()
  29. {
  30. _solutionService.CreateProjectTemplatesFromSolution(" ", "","");
  31. }
  32. [TestMethod]
  33. [ExpectedException(typeof(InvalidSolutionPathException), "Le chemin de la solution passé en premier paramètre n'est pas valide !")]
  34. public void TestInvalidSolutionPathError03()
  35. {
  36. _solutionService.CreateProjectTemplatesFromSolution(@"C:/abc*d.txt", "","");
  37. }
  38. [TestMethod]
  39. [ExpectedException(typeof(ExtensionSolutionPathException), "Le chemin de la solution passé en premier paramètre n'existe pas !")]
  40. public void ExtensionSolutionPathError04()
  41. {
  42. _solutionService.CreateProjectTemplatesFromSolution(@"C:/toto.txt", "","");
  43. }
  44. [TestMethod]
  45. [ExpectedException(typeof(SolutionPathIsNotAFileException), "Le chemin de la solution passé en premier paramètre n'existe pas !")]
  46. public void SolutionPathIsNotAFileError05()
  47. {
  48. _solutionService.CreateProjectTemplatesFromSolution(@"C:/toto.sln", "","");
  49. }
  50. [TestMethod]
  51. [ExpectedException(typeof(DirectoryDestinationIsNullException), "Le chemin de destination passé en second paramètre ne doit pas être null !")]
  52. public void DirectoryDestinationIsNullError06()
  53. {
  54. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), null,"");
  55. }
  56. [TestMethod]
  57. [ExpectedException(typeof(DirectoryDestinationIsEmptyException), "Le chemin de destination passé en second paramètre ne doit pas être vide !")]
  58. public void DirectoryDestinationIsEmptyError07()
  59. {
  60. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), " ","");
  61. }
  62. [TestMethod]
  63. [ExpectedException(typeof(InvalideDirectoryDestinationException), "Le chemin de destination passé en second paramètre ne doit pas être vide !")]
  64. public void InvalideDirectoryDestinationError08()
  65. {
  66. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), @"C:/abc*d","");
  67. }
  68. [TestMethod]
  69. [ExpectedException(typeof(DirectoryDestinationNotFoundException), "Le chemin de destination passé en second paramètre est un chemin inexistant !")]
  70. public void DirectoryDestinationNotFoundError09()
  71. {
  72. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), @"C:/abcd","");
  73. }
  74. [TestMethod]
  75. [ExpectedException(typeof(NewSolutionIsNullException), "La nouvelle solution passée en second paramètre est null !")]
  76. public void NewSolutionIsNullError10()
  77. {
  78. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),null);
  79. }
  80. [TestMethod]
  81. [ExpectedException(typeof(NewSolutionIsEmptyException), "La nouvelle solution passée en second paramètre est vide !")]
  82. public void NewSolutionIsEmptyError11()
  83. {
  84. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), " ");
  85. }
  86. [TestMethod]
  87. [ExpectedException(typeof(ExtensionNewSolutionException), "La nouvelle solution passée en second paramètre n'as pas l'extension sln!")]
  88. public void ExtensionNewSolutioError12()
  89. {
  90. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "toto.sn");
  91. }
  92. [TestMethod]
  93. public void TestSolutionNominal01()
  94. {
  95. _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Test.sln");
  96. }
  97. }
  98. }