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

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

            templateLoader.Load(Path.Combine(curentPath, "TestData\\method-config.xml"));
            var template           = templateLoader.Templates.FirstOrDefault(tmp => tmp.TemplateName == "CSharp");
            var eventData          = CommonData.EventSpecificDataTypeList.FirstOrDefault(ed => ed.EventSpecificData == EventSpecificData.None);
            var methodName         = "TestMethod";
            var isUsedVSFormatting = false;
            var expectedWrapper    = File.ReadAllText(Path.Combine(curentPath, "Code\\TestData\\CreateWrapper\\WrapperCodeInfo.txt"));

            //Act
            var expected = codeProvider.CreateWrapper(template, eventData, methodName, isUsedVSFormatting);

            //Assert
            Assert.AreEqual(expected.ClassName, "ArasCLS" + methodName);
            Assert.AreEqual(expected.IsUseVSFormatting, isUsedVSFormatting);
            Assert.AreEqual(expected.MethodCodeParentClassName, "ItemMethod");
            Assert.AreEqual(expected.MethodName, methodName);
            Assert.AreEqual(expected.Namespace, "ArasPKG" + methodName);
            Assert.AreEqual(expected.PartialCodeInfoList.Count, 0);
            Assert.AreEqual(expected.WrapperCodeInfo.Code, expectedWrapper);
            Assert.AreEqual(expected.WrapperCodeInfo.Path, methodName + "\\" + methodName + "Wrapper.cs");
        }