Beispiel #1
0
        public void finds_property_name()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.IsTrue(description.Properties.Any(p => p.Name == "Blah"));
            Assert.IsTrue(description.Properties.Any(p => p.Name == "Wololo"));
        }
Beispiel #2
0
        public void finds_function_names()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.IsTrue(description.Functions.Any(f => f.Name == "DoSmth"));
            Assert.IsTrue(description.Functions.Any(f => f.Name == "DoSmthElse"));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if (args.Length != 1 || !File.Exists(args[0]))
            {
                Console.WriteLine($"Usage: {Environment.CommandLine.Split(' ')[0]} path_to_test_file");
                return;
            }
            var fixtureContent = File.ReadAllText(args[0]);
            var description    = FixtureAnalyzer.ExtractSpecification(fixtureContent);
            var generator      = new ClassGenerator(description);
            var code           = generator.GenerateClass();
            var classPath      = description.Name + ".cs";

            if (File.Exists(classPath))
            {
                Console.WriteLine($"{classPath} already exists. Overwrite? [Y]es / [N]o ");
                var key = Console.ReadKey();
                if (key.KeyChar != 'Y' && key.KeyChar != 'y')
                {
                    return;
                }
            }
            File.WriteAllText(classPath, code);
        }
Beispiel #4
0
        public void default_argument_type_is_object()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("object", description.Functions.First(f => f.Name == "DoSmthElse").Arguments.First());
        }
Beispiel #5
0
        public void recognizes_argument_type()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("string", description.Functions.First(f => f.Name == "DoSmth").Arguments.First());
        }
Beispiel #6
0
        public void finds_arguments_number()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual(1, description.Functions.First(f => f.Name == "DoSmth").Arguments.Count());
        }
Beispiel #7
0
        public void finds_return_types()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("int", description.Functions.First(f => f.Name == "DoSmthElse").ReturnType);
        }
Beispiel #8
0
        public void default_function_return_type_is_void()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("void", description.Functions.First(f => f.Name == "DoSmth").ReturnType);
        }
Beispiel #9
0
        public void finds_functions()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual(2, description.Functions.Count());
        }
Beispiel #10
0
        public void parses_name()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("SampleClass", description.Name);
        }
Beispiel #11
0
 public void does_not_throw_on_sample_use()
 {
     FixtureAnalyzer.ExtractSpecification(_sampleTestFile);
 }
Beispiel #12
0
        public void property_is_object_by_default()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("object", description.Properties.First(p => p.Name == "Wololo").Type);
        }
Beispiel #13
0
        public void finds_property_type()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.AreEqual("string", description.Properties.First(p => p.Name == "Blah").Type);
        }
Beispiel #14
0
        public void recognizes_settable_properties()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.IsTrue(description.Properties.First(p => p.Name == "Blah").HasSetter);
        }
Beispiel #15
0
        public void property_is_readonly_by_default()
        {
            var description = FixtureAnalyzer.ExtractSpecification(_sampleTestFile);

            Assert.IsFalse(description.Properties.First(p => p.Name == "Wololo").HasSetter);
        }