Exemplo n.º 1
0
        public void BuildFile_EmptyClassInfo_CannotBuildFile()
        {
            bool expected = false;

            string       validationResult = "";
            ClassInfo    oClassInfo       = new SoftwareDesignerLibrary.ClassInfo();
            ClassBuilder builder          = new SoftwareDesignerLibrary.ClassBuilder();

            builder.CodeBuilder = new CSharpCodeBuilder();
            builder.oClassInfo  = oClassInfo;

            bool actual = builder.CanBuildFile(validationResult);

            Assert.True(actual == expected);
        }
Exemplo n.º 2
0
        public void BuildFile_FillClassName_CanBuildFile()
        {
            bool expected = true;

            string    validationResult = "";
            ClassInfo oClassInfo       = new SoftwareDesignerLibrary.ClassInfo();

            oClassInfo.ClassName = nameof(BuildFile_FillClassName_CanBuildFile);
            ClassBuilder builder = new SoftwareDesignerLibrary.ClassBuilder();

            builder.CodeBuilder = new CSharpCodeBuilder();
            builder.oClassInfo  = oClassInfo;

            bool actual = builder.CanBuildFile(validationResult);

            Assert.True(actual == expected);
        }
        public void BuildFile_CSharpClass_ContainsSubstring(string[] expectedSubstrings,
                                                            string[] inputProperties,
                                                            string[] inputMethods)
        {
            ClassInfo oClassInfo = new SoftwareDesignerLibrary.ClassInfo();

            oClassInfo.ClassName = nameof(BuildFile_CSharpClass_ContainsSubstring);
            oClassInfo.AddProperties(inputProperties);
            oClassInfo.AddMethods(inputMethods);

            string[] files = Services.CodeBuilderService.GenerateFiles("CSharp", new ClassInfo[] { oClassInfo }, null);

            string actualFile   = files.First();
            string actualString = System.IO.File.ReadAllText(actualFile);

            foreach (string expectedSubstring in expectedSubstrings)
            {
                Assert.Contains(expectedSubstring, actualString);
            }
        }