|
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using SIE.IVSDK.Services;
- using SIE.VSDK.Exceptions.DirectoryDestination;
- using SIE.VSDK.Exceptions.Solution;
- using SIE.VSDK.Services;
- using System;
- using System.IO;
-
- namespace SIE.VSDK.Test
- {
- [TestClass]
- public class SolutionServiceTest
- {
- private readonly ISolutionService _solutionService;
- private string dirTest = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).FullName).FullName).FullName).FullName;
- public SolutionServiceTest()
- {
- IPathService pathService = new PathService();
- _solutionService = new SolutionService(pathService);
- }
-
-
- [TestMethod]
- [ExpectedException(typeof(SolutionPathIsNullException), "Le chemin de la solution passé en premier paramètre est null !")]
- public void TestSolutionPathIsNullError01()
- {
- _solutionService.CreateProjectTemplatesFromSolution(null, "","");
- }
-
- [TestMethod]
- [ExpectedException(typeof(SolutionPathIsEmptyException), "Le chemin de la solution passé en premier paramètre eqt vide !")]
- public void TestSolutionPathIsNotAFileError02()
- {
- _solutionService.CreateProjectTemplatesFromSolution(" ", "","");
- }
- [TestMethod]
- [ExpectedException(typeof(InvalidSolutionPathException), "Le chemin de la solution passé en premier paramètre n'est pas valide !")]
- public void TestInvalidSolutionPathError03()
- {
- _solutionService.CreateProjectTemplatesFromSolution(@"C:/abc*d.txt", "","");
- }
- [TestMethod]
- [ExpectedException(typeof(ExtensionSolutionPathException), "Le chemin de la solution passé en premier paramètre n'existe pas !")]
- public void ExtensionSolutionPathError04()
- {
- _solutionService.CreateProjectTemplatesFromSolution(@"C:/toto.txt", "","");
- }
-
- [TestMethod]
- [ExpectedException(typeof(SolutionPathIsNotAFileException), "Le chemin de la solution passé en premier paramètre n'existe pas !")]
- public void SolutionPathIsNotAFileError05()
- {
- _solutionService.CreateProjectTemplatesFromSolution(@"C:/toto.sln", "","");
- }
- [TestMethod]
- [ExpectedException(typeof(DirectoryDestinationIsNullException), "Le chemin de destination passé en second paramètre ne doit pas être null !")]
- public void DirectoryDestinationIsNullError06()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), null,"");
- }
- [TestMethod]
- [ExpectedException(typeof(DirectoryDestinationIsEmptyException), "Le chemin de destination passé en second paramètre ne doit pas être vide !")]
- public void DirectoryDestinationIsEmptyError07()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), " ","");
- }
- [TestMethod]
- [ExpectedException(typeof(InvalideDirectoryDestinationException), "Le chemin de destination passé en second paramètre ne doit pas être vide !")]
- public void InvalideDirectoryDestinationError08()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), @"C:/abc*d","");
- }
- [TestMethod]
- [ExpectedException(typeof(DirectoryDestinationNotFoundException), "Le chemin de destination passé en second paramètre est un chemin inexistant !")]
- public void DirectoryDestinationNotFoundError09()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), @"C:/abcd","");
- }
- [TestMethod]
- [ExpectedException(typeof(NewSolutionIsNullException), "La nouvelle solution passée en second paramètre est null !")]
- public void NewSolutionIsNullError10()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),null);
- }
- [TestMethod]
- [ExpectedException(typeof(NewSolutionIsEmptyException), "La nouvelle solution passée en second paramètre est vide !")]
- public void NewSolutionIsEmptyError11()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), " ");
- }
- [TestMethod]
- [ExpectedException(typeof(ExtensionNewSolutionException), "La nouvelle solution passée en second paramètre n'as pas l'extension sln!")]
- public void ExtensionNewSolutioError12()
- {
-
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "toto.sn");
- }
-
- [TestMethod]
- public void TestSolutionNominal01()
- {
- _solutionService.CreateProjectTemplatesFromSolution(Path.Combine(dirTest, "WebApplication1", "WebApplication1.sln"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Test.sln");
- }
-
-
-
-
-
-
-
-
-
- }
- }
|