Ejemplo n.º 1
0
        public void GenerateSchemaClassesTest()
        {
            var generator   = new GoogleSchemaGenerator(new List <ISchemaDecorator>(), "Fish.Chips");
            var mockService = new MockService();

            var mockSchema = new MockSchema();

            mockSchema.Id            = "Fish";
            mockSchema.Name          = "Fish";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Fish", mockSchema);

            mockSchema               = new MockSchema();
            mockSchema.Id            = "Chips";
            mockSchema.Name          = "Chips";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Chips", mockSchema);

            CodeNamespace result = generator.GenerateSchemaClasses(mockService);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Types.Count);
            List <string> classNames = new List <string>(2);

            classNames.Add(result.Types[0].Name);
            classNames.Add(result.Types[1].Name);

            Assert.That(classNames.Contains("Fish"));
            Assert.That(classNames.Contains("Chips"));
        }
        public void GenerateSchemaClassesTest()
        {
            var generator = new GoogleSchemaGenerator(new List<ISchemaDecorator>(), "Fish.Chips");
            var mockService = new MockService();

            var mockSchema = new MockSchema();
            mockSchema.Id = "Fish";
            mockSchema.Name = "Fish";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Fish", mockSchema);

            mockSchema = new MockSchema();
            mockSchema.Id = "Chips";
            mockSchema.Name = "Chips";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Chips", mockSchema);

            CodeNamespace result = generator.GenerateSchemaClasses(mockService);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Types.Count);
            List<string> classNames = new List<string>(2);
            classNames.Add(result.Types[0].Name);
            classNames.Add(result.Types[1].Name);

            Assert.That(classNames.Contains("Fish"));
            Assert.That(classNames.Contains("Chips"));
        }
 public void GenerateSchemaClassesParameterValidationTest()
 {
     var generator = new GoogleSchemaGenerator(new List<ISchemaDecorator>(), "Fish.Chips");
     Assert.Throws(typeof(ArgumentNullException), () => generator.GenerateSchemaClasses(null));
     var mockService = new MockService();
     Assert.DoesNotThrow(() => generator.GenerateSchemaClasses(mockService));
 }
Ejemplo n.º 4
0
        public void GenerateSchemaClassesParameterValidationTest()
        {
            var generator = new GoogleSchemaGenerator(new List <ISchemaDecorator>(), "Fish.Chips");

            Assert.Throws(typeof(ArgumentNullException), () => generator.GenerateSchemaClasses(null));
            var mockService = new MockService();

            Assert.DoesNotThrow(() => generator.GenerateSchemaClasses(mockService));
        }