コード例 #1
0
        public static string GetTestHelpers(JsonSchema4 schema, string ns, out string inputToEntityEqualAssertFunc, out string entityToViewEqualAssertFunc, out string createInputFunc, out string createEntityFunc, out string createViewFunc)
        {
            String createArgs = "";

            inputToEntityEqualAssertFunc = "";
            if (schema.CreateInputModel() && schema.CreateEntity())
            {
                inputToEntityEqualAssertFunc = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new ModelEqualityAssert(i => i.OnInputModel && i.OnEntity, "Input", "Entity"), schema, ns, ns);
            }

            entityToViewEqualAssertFunc = "";
            if (schema.CreateEntity() && schema.CreateViewModel())
            {
                entityToViewEqualAssertFunc = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new ModelEqualityAssert(i => i.OnEntity && i.OnViewModel, "Entity", ""), schema, ns, ns);
            }

            createInputFunc = "";
            if (schema.CreateInputModel())
            {
                createArgs      = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new ModelCreateArgs(), schema, ns, ns, p => p.CreateInputModel());
                createInputFunc = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new CreateInputModel(createArgs), schema, ns, ns, p => p.CreateInputModel());
            }

            createEntityFunc = "";
            if (schema.CreateEntity())
            {
                createArgs       = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new ModelCreateArgs(), schema, ns, ns, p => p.CreateEntity());
                createEntityFunc = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new CreateEntity(schema, createArgs), schema, ns, ns, p => p.CreateEntity());
            }

            createViewFunc = "";
            if (schema.CreateViewModel())
            {
                createArgs     = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new ModelCreateArgs(), schema, ns, ns, p => p.CreateViewModel());
                createViewFunc = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new CreateViewModel(schema, createArgs), schema, ns, ns, p => p.CreateViewModel());
            }

            return(createArgs);
        }