Ejemplo n.º 1
0
        public void JavaModelBuilder_BuildsCorrectModel()
        {
            var javaModelBuilder = new JavaModelBuilder(typeof(RootObject));

            var expectedJavaModel = ExpectedJavaModel.GetFullJavaModel();
            var actualJavaModel   = javaModelBuilder.Build();

            VerifyJavaModel(expectedJavaModel, actualJavaModel);
        }
        public void GenerateClassDefinition_GeneratesCorrectDefinition()
        {
            var javaClass = ExpectedJavaModel.GetFullJavaModel()
                            .Single(c => c.ClassName == "RootObject");

            var fileBuilder       = new JavaFileBuilder();
            var classDefGenerator = new JavaClassDefinitionGenerator(fileBuilder, javaClass);

            classDefGenerator.GenerateClassDefinition();

            var result         = fileBuilder.GetFileContents();
            var expectedResult = c_correctDefinition.Replace("\r\n", "\n");

            Assert.Equal(expectedResult, result);
        }
        public void GenerateConstructorInvocation_GeneratesCorrectInvocation()
        {
            var fileBuilder = new JavaFileBuilder();
            var javaModel   = ExpectedJavaModel.GetFullJavaModel();
            var constructorInvocationGen = new JavaConstructorInvocationGenerator
                                           (
                fileBuilder,
                javaModel
                                           );

            constructorInvocationGen.GenerateConstructorInvocation
            (
                GetRootObject(),
                "return ",
                ";"
            );

            var result         = fileBuilder.GetFileContents();
            var expectedResult = c_correctInvocation.Replace("\r\n", "\n");

            Assert.Equal(expectedResult, result);
        }