示例#1
0
            public void GeneratesOverloadedConstructors()
            {
                // Given
                Dictionary <string, string> memberNames = new Dictionary <string, string>();
                string expected = $@"
                        public static Wyam.Core.Modules.Contents.Content Content(object content)
                        {{
                            return new Wyam.Core.Modules.Contents.Content(content);  
                        }}
                        public static Wyam.Core.Modules.Contents.Content Content(Wyam.Common.Configuration.ContextConfig content)
                        {{
                            return new Wyam.Core.Modules.Contents.Content(content);  
                        }}
                        public static Wyam.Core.Modules.Contents.Content Content(Wyam.Common.Configuration.DocumentConfig content)
                        {{
                            return new Wyam.Core.Modules.Contents.Content(content);  
                        }}
                        public static Wyam.Core.Modules.Contents.Content Content(params Wyam.Common.Modules.IModule[] modules)
                        {{
                            return new Wyam.Core.Modules.Contents.Content(modules);  
                        }}";

                // When
                string generated = ConfigScript.GenerateModuleConstructorMethods(typeof(Content), memberNames);

                // Then
                Assert.AreEqual(expected, generated);
            }
示例#2
0
            public void GeneratesGenericConstructors()
            {
                // Given
                Dictionary <string, string> memberNames = new Dictionary <string, string>();
                string expected = $@"
                        public static Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T> GenericModule<T>(T input)
                        {{
                            return new Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T>(input);  
                        }}
                        public static Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T> GenericModule<T>(System.Action<T> input)
                        {{
                            return new Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T>(input);  
                        }}";

                // When
                string generated = ConfigScript.GenerateModuleConstructorMethods(typeof(GenericModule <>), memberNames);

                // Then
                Assert.AreEqual(expected, generated);
            }