public void RamlMapper_CreateOneApiWithNullType_DoNotDisplayTypeField() { expectedHeader[0].Type = null; expectedHeaderAttributes[0].Type = null; expectedModel.Routes[0].Headers = new List <RequestHeaderModel> { expectedHeader[0] }; var headerAttribute = new Collection <RequestHeadersAttribute> { expectedHeaderAttributes[0] }; mockActionDescriptor.Setup(p => p.GetCustomAttributes <RequestHeadersAttribute>()) .Returns(headerAttribute); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); var r = result.ToString(); Assert.IsTrue(result.ToString().Contains("headers:")); Assert.IsFalse(result.ToString().Contains(" type:")); }
public void RAMLSharp_CreateRamlDocumentWithOneApi_GenerateRAMLWithOneAPI() { expectedModel.Routes = new List <RouteModel> { new RouteModel { UrlTemplate = "api/test", Verb = "get" } }; IEnumerable <ApiDescription> model = new List <ApiDescription>() { new ApiDescription { HttpMethod = new System.Net.Http.HttpMethod("get"), RelativePath = "api/test" } }; var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RAMLSharp_CreateRamlDocumentWithNullAPIs_DisplayBasicRAMLDocument() { IEnumerable<ApiDescription> modelApiDescription = null; var subject = new RAMLMapper(modelApiDescription); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RAMLSharp_CreateRamlDocumentWithNullAPIs_DisplayBasicRAMLDocument() { IEnumerable <ApiDescription> modelApiDescription = null; var subject = new RAMLMapper(modelApiDescription); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RAMLSharp_CreateRamlDocumentWithProtocol_GenerateRAMLWithProtocol() { IEnumerable <ApiDescription> model = null; var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.IsTrue(result.ToString().Contains("protocols: [HTTP]")); }
public void RAMLSharp_CreateRamlDocumentWithDescription_GenerateRAMLWithDescription() { IEnumerable<ApiDescription> model = null; var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.IsTrue(result.ToString().Contains("content:")); }
public void RAMLSharp_CreateRamlDocumentWithNullUri_DisplayBasicRAMLDocumentWithoutURI() { expectedModel.BaseUri = null; var model = new List <ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(expectedModel.BaseUri, "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RAMLSharp_CreateRamlDocumentWithNullBaseMediaType_DisplayBasicRAMLDocumentWithoutMediaType() { expectedModel.DefaultMediaType = null; var model = new List<ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", expectedModel.DefaultMediaType, "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsFalse(result.ToString().Contains("mediaType:")); }
public void RAMLSharp_CreateRamlDocumentWithNullVersion_DisplayBasicRAMLDocumentWithoutVersion() { expectedModel.Version = null; var model = new List <ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", expectedModel.Version, "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsFalse(result.ToString().Contains("version:")); }
public void RAMLSharp_CreateRamlDocumentWithNullBaseMediaType_DisplayBasicRAMLDocumentWithoutMediaType() { expectedModel.DefaultMediaType = null; var model = new List <ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", expectedModel.DefaultMediaType, "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsFalse(result.ToString().Contains("mediaType:")); }
public HttpResponseMessage RAML() { var result = new HttpResponseMessage(HttpStatusCode.OK); var r = new RAMLMapper(this); var data = r.WebApiToRamlModel (new Uri ("http://www.google.com"), "Test API", "1", "application/json", "This is a test"); result.Content = new StringContent(data.ToString()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/raml+yaml"); result.Content.Headers.ContentLength = data.ToString().Length; return result; }
public void RAMLSharp_CreateRamlDocumentWithNullTitle_DisplayBasicRAMLDocumentWithBlankTitle() { expectedModel.Title = null; var model = new List <ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), expectedModel.Title, "1", "application/json", "test"); var r = result.ToString(); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsTrue(result.ToString().Contains("title:")); }
public HttpResponseMessage RAML() { var result = new HttpResponseMessage(HttpStatusCode.OK); var r = new RAMLMapper(this); var data = r.WebApiToRamlModel(new Uri("http://www.google.com"), "Test API", "1", "application/json", "This is a test"); result.Content = new StringContent(data.ToString()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/raml+yaml"); result.Content.Headers.ContentLength = data.ToString().Length; return(result); }
public void RamlMapper_CreateNullResponseBody_GenerateRAML() { expectedResponseBodyAttributes = null; mockActionDescriptor.Setup(p => p.GetCustomAttributes <ResponseBodyAttribute>()) .Returns(expectedResponseBodyAttributes); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.IsFalse(result.ToString().Contains(" body:")); Assert.IsFalse(result.ToString().Contains(" application/json:")); Assert.IsFalse(result.ToString().Contains(" application/xml:")); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RamlMapper_CreateOneApiWithMultipleHeaders_Display2Headers() { expectedModel.Routes[0].Headers = expectedHeader; mockActionDescriptor.Setup(p => p.GetCustomAttributes <RequestHeadersAttribute>()) .Returns(expectedHeaderAttributes); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsTrue(result.ToString().Contains("headers:")); Assert.IsTrue(result.ToString().Contains("Accept:")); Assert.IsTrue(result.ToString().Contains("Date:")); }
public void RamlMapper_CreateEmptyResponseBody_GenerateRAML() { expectedResponseBody = new List<ResponseModel>(); expectedResponseBodyAttributes = new Collection<ResponseBodyAttribute>(); mockActionDescriptor.Setup(p => p.GetCustomAttributes<ResponseBodyAttribute>()) .Returns(expectedResponseBodyAttributes); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.IsFalse(result.ToString().Contains(" body:")); Assert.IsFalse(result.ToString().Contains(" application/json:")); Assert.IsFalse(result.ToString().Contains(" application/xml:")); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RamlMapper_CreateOneApiWithTwoNullName_DoNotDisplayHeaderSection() { expectedHeader[0].Name = null; expectedHeader[1].Name = null; expectedModel.Routes[0].Headers = expectedHeader; expectedHeaderAttributes[0].Name = null; expectedHeaderAttributes[1].Name = null; mockActionDescriptor.Setup(p => p.GetCustomAttributes <RequestHeadersAttribute>()) .Returns(expectedHeaderAttributes); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsFalse(result.ToString().Contains("headers:")); }
public void RamlMapper_CreateNullDescription_GenerateRAMLWithoutDescription() { expectedResponseBody[0].Example = null; expectedResponseBodyAttributes[0].Example = null; expectedResponseBody[1].Example = null; expectedResponseBodyAttributes[1].Example = null; expectedModel.Routes[0].Responses = expectedResponseBody; mockActionDescriptor.Setup(p => p.GetCustomAttributes<ResponseBodyAttribute>()) .Returns(expectedResponseBodyAttributes); var subject = new RAMLMapper(descriptions); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsTrue(result.ToString().Contains(" body:")); Assert.IsTrue(result.ToString().Contains(" application/json:")); Assert.IsFalse(result.ToString().Contains(" description:")); }
public void RAMLSharp_CreateRamlDocumentWithNullTitle_DisplayBasicRAMLDocumentWithBlankTitle() { expectedModel.Title = null; var model = new List<ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), expectedModel.Title, "1", "application/json", "test"); var r = result.ToString(); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsTrue(result.ToString().Contains("title:")); }
public void RAMLSharp_CreateRamlDocumentWithNullUri_DisplayBasicRAMLDocumentWithoutURI() { expectedModel.BaseUri = null; var model = new List<ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(expectedModel.BaseUri, "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }
public void RAMLSharp_CreateRamlDocumentWithNullVersion_DisplayBasicRAMLDocumentWithoutVersion() { expectedModel.Version = null; var model = new List<ApiDescription>(); var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", expectedModel.Version, "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); Assert.IsFalse(result.ToString().Contains("version:")); }
public void RAMLSharp_CreateRamlDocumentWithOneApi_GenerateRAMLWithOneAPI() { expectedModel.Routes = new List<RouteModel> { new RouteModel { UrlTemplate="api/test", Verb="get" } }; IEnumerable<ApiDescription> model = new List<ApiDescription>() { new ApiDescription { HttpMethod = new System.Net.Http.HttpMethod("get"), RelativePath = "api/test" } }; var subject = new RAMLMapper(model); var result = subject.WebApiToRamlModel(new Uri("http://www.test.com"), "test", "1", "application/json", "test"); Assert.AreEqual(expectedModel.ToString(), result.ToString(), "The RAML string must be the same."); }