////////////////////////////////////////////////////////////// // Copyright file = "AddPythonScript.cs" // // Copyright (c) 2020 All Rights Reserved // // Authors: Francine Rotzetter / Robin Dittli // // Date: 21/01/2020 // // Summary: Class representing a Python script generator // ////////////////////////////////////////////////////////////// using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.IO; namespace THUMM.Tests { //Unit Tests for Python file creation //and path directory check // [TestClass()] public class TestingClass { //Test for constructor [TestMethod()] public void AddPythonScript_CreatesClass_WithCorrectDestinationPath() { //Create Class AddPythonScript py = new AddPythonScript("OpenBlender.py"); //Build correct output path string pyFullPath = AppDomain.CurrentDomain.BaseDirectory + "\\OpenBlender.py"; //act and assert //Checking if python filepath is combined correct Assert.AreEqual(py.PythonOutputPath, pyFullPath); } //Test for Python file creation [TestMethod()] public void CreatePyFile_CreatesAFile_AtDefaultPath() { //Create Class AddPythonScript py = new AddPythonScript("OpenBlender.py"); //Get output path string defaultOutputPath = py.PythonOutputPath; //Delete File if it exists if(File.Exists(defaultOutputPath)) { File.Delete(defaultOutputPath); } //Create File py.CreatePyFile(); //Log: Console.WriteLine("Checked path: " + defaultOutputPath); //Test succeeds if there is a file at the target location Assert.IsTrue(File.Exists(defaultOutputPath)); } } }