Exemple #1
0
        public void CreateTestsNew_ShouldReturnCorrectTestCode()
        {
            //Arrange
            var currentPath = System.AppDomain.CurrentDomain.BaseDirectory;

            projectManager.DefaultCodeTemplatesPath.Returns(Path.Combine(currentPath, "TestData"));
            var templateLoader = new TemplateLoader();

            templateLoader.Load(Path.Combine(currentPath, "TestData\\method-config.xml"));
            var template          = templateLoader.Templates.FirstOrDefault(tmp => tmp.TemplateName == "CSharp");
            var methodName        = "MethodTest";
            var eventData         = CommonData.EventSpecificDataTypeList.FirstOrDefault(ed => ed.EventSpecificData == EventSpecificData.None);
            var generatedCodeInfo = new GeneratedCodeInfo()
            {
                ClassName         = "ArasCLS" + methodName,
                IsUseVSFormatting = false,
                Namespace         = "ArasPKG" + methodName,
            };

            //Act
            var expected = codeProvider.CreateTestsNew(generatedCodeInfo, template, eventData, methodName, false);

            //Assert
            Assert.AreEqual(expected.TestsCodeInfo.Path, @"MethodTest\MethodTestTests.cs");
            Assert.AreEqual(expected.TestsCodeInfo.Code, File.ReadAllText(Path.Combine(currentPath, "Code\\TestData\\CreateTestsNew\\ExpectedTestCode.txt")));
        }