public void CorrectlyReferencedServicesShouldBeIncludedInSMD() { var xmlDocSource = new XmlDocSource(); xmlDocSource.Dtos.Add(AssemblyWithXmlDocs.CreateFromName("TestAssembly.DTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", ".")); xmlDocSource.RouteAssembly = AssemblyWithXmlDocs.CreateFromName("TestAssembly.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "."); xmlDocSource.Routes = new List <RouteElement> { new RouteElement { Endpoint = "/session", Name = "session", Type = "TestAssembly.Service.ITestService, TestAssembly.Service, Version=1.0.0.0" }, new RouteElement { Endpoint = "/session", Name = "session_logout", Type = "TestAssembly.Service.ITestService, TestAssembly.Service, Version=1.0.0.0" } }; var jsonSchema = new JsonSchemaDtoEmitter().EmitDtoJson(xmlDocSource); var smdSchema = new WcfSMD.Emitter().EmitSmdJson(xmlDocSource, true, jsonSchema); Console.WriteLine(smdSchema.SMD); Assert.That(smdSchema.SMD["services"]["rpc"]["services"]["CreateSession"], Is.Not.Null); Assert.That(smdSchema.SMD["services"]["rpc"]["services"]["DeleteSession"], Is.Not.Null); }
public void APropertyWithPublicFieldShouldThrow() { try { var type = typeof(TestAssembly.BadDTO.ClassWithPublicField); JsonSchemaDtoEmitter.RenderType(type, new JObject()); } catch (MetadataValidationException ex) { Assert.AreEqual("TestAssembly.BadDTO.ClassWithPublicField. : Errors occured generating type meta.\r\n\tTestAssembly.BadDTO.ClassWithPublicField.AProperty : A DTO type must not implement public fields\r\n", ex.ToString()); } }
public void APropertyMissingJschemaShouldThrow() { try { var type = typeof(TestAssembly.BadDTO.ClassWithMissingPropertyJschema); JsonSchemaDtoEmitter.RenderType(type, new JObject()); } catch (MetadataValidationException ex) { Assert.AreEqual(1, ex.AggregatedExceptions.Count, "should have one exception"); Assert.AreEqual("TestAssembly.BadDTO.ClassWithMissingPropertyJschema. : Errors occured generating type meta.\r\n\tTestAssembly.BadDTO.ClassWithMissingPropertyJschema.AProperty : Member does not have <jschema> element. All DTO properties must have a jschema element\r\n", ex.ToString()); } }
public void WebInvokeMethodGetShouldBeIncludedAsGet() { var xmlDocSource = CreateXmlDocSourceForTestAssembly( new List <RouteElement> { new RouteElement { Endpoint = "/WebInvokeMethodGet", Name = "WebInvokeMethodGet", Type = "TestAssembly.Service.ITestService, TestAssembly.Service, Version=1.0.0.0" } }); var jsonSchema = new JsonSchemaDtoEmitter().EmitDtoJson(xmlDocSource); var smdSchema = new WcfSMD.Emitter().EmitSmdJson(xmlDocSource, true, jsonSchema); Console.WriteLine(smdSchema.SMD); Assert.That(smdSchema.SMD["services"]["rpc"]["services"]["WebInvokeMethodGet"], Is.Not.Null, "SMD doesn't contain WebInvokeMethodGet"); }
public void WebInvokeMethodDELETEmethodsAreSupported() { var xmlDocSource = CreateXmlDocSourceForTestAssembly( new List <RouteElement> { new RouteElement { Endpoint = "/IServiceWithDELETEandPUTMethods/delete", Name = "DeleteEndpoint", Type = "TestAssembly.Service.IServiceWithDELETEandPUTMethods, TestAssembly.Service, Version=1.0.0.0" } }); var jsonSchema = new JsonSchemaDtoEmitter().EmitDtoJson(xmlDocSource); var smdSchema = new WcfSMD.Emitter().EmitSmdJson(xmlDocSource, true, jsonSchema); smdSchema.MetadataGenerationErrors.ForEach(e => Console.WriteLine(e.ToString())); Assert.That(smdSchema.HasErrors, Is.True, "There should have been a generation error"); Assert.That(smdSchema.MetadataGenerationErrors.ToList().FirstOrDefault(e => e.ErrorReason.Contains("DELETE")), Is.Not.Null, "There should have been a generation error for the DELETE method"); }
public void ExcludeAttributeOnMethodShouldOmitServiceMethod() { var xmlDocSource = CreateXmlDocSourceForTestAssembly( new List <RouteElement> { new RouteElement { Endpoint = "/PartiallyExcludedService/included", Name = "IncludedEndpoint", Type = "TestAssembly.Service.IPartiallyExcludedService, TestAssembly.Service, Version=1.0.0.0" }, new RouteElement { Endpoint = "/PartiallyExcludedService/excluded", Name = "ExcludedEndpoint", Type = "TestAssembly.Service.IPartiallyExcludedService, TestAssembly.Service, Version=1.0.0.0" }, }); var jsonSchema = new JsonSchemaDtoEmitter().EmitDtoJson(xmlDocSource); var smdSchema = new WcfSMD.Emitter().EmitSmdJson(xmlDocSource, true, jsonSchema); Console.WriteLine(smdSchema.SMD); Assert.That(smdSchema.SMD["services"]["rpc"]["services"]["IncludedEndpoint"], Is.Not.Null, "SMD should contain definition for IncludedEndpoint"); Assert.That(smdSchema.SMD["services"]["rpc"]["services"]["ExcludedEndpoint"], Is.Null, "SMD should not contain definition for ExcludedEndpoint"); }