Exemplo n.º 1
0
        public void GetParameterListFromOperationSegment_ShouldReturnStringWithDoubleQuotesForOdataActionParameter()
        {
            //Arrange
            var requestPayload   = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/worksheets/{id|name}/range(address='A1:B2')");
            var snippetModel     = new SnippetModel(requestPayload, ServiceRootUrl, _edmModel);
            var operationSegment = snippetModel.Segments.Last() as OperationSegment;

            //Act
            var result = CommonGenerator.GetParameterListFromOperationSegment(operationSegment, snippetModel);

            //Assert the string parameter is now double quoted
            Assert.Equal("\"A1:B2\"", result.First());
        }
Exemplo n.º 2
0
        public void GetParameterListFromOperationSegment_ShouldSetOptionalUnprovidedParameterToNull()
        {
            //Arrange
            const string jsonObject = "{\r\n  " +
                                      "\"hasHeaders\": true\r\n" +//we have not provided the optional address parameter
                                      "}";
            var requestPayload = new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/add")
            {
                Content = new StringContent(jsonObject)
            };
            var snippetModel     = new SnippetModel(requestPayload, ServiceRootUrl, _edmModel);
            var operationSegment = snippetModel.Segments.Last() as OperationSegment;

            //Act
            var result = CommonGenerator.GetParameterListFromOperationSegment(operationSegment, snippetModel).ToList();

            //Assert the parameters are ordered as expected
            Assert.Equal("hasHeaders", result[0]);
            Assert.Equal("null", result[1]);
        }
Exemplo n.º 3
0
        public void GetParameterListFromOperationSegment_ShouldReturnParameterListOrderedByMetadataReference()
        {
            //Arrange
            const string jsonObject = "{\r\n  " +
                                      "\"address\": \"Sheet1!A1:D5\",\r\n" +
                                      "\"hasHeaders\": true\r\n" +
                                      "}";
            var requestPayload = new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/add")
            {
                Content = new StringContent(jsonObject)
            };
            var snippetModel     = new SnippetModel(requestPayload, ServiceRootUrl, _edmModel);
            var operationSegment = snippetModel.Segments.Last() as OperationSegment;

            //Act
            var result = CommonGenerator.GetParameterListFromOperationSegment(operationSegment, snippetModel, "", false).ToList();

            //Assert the parameters are ordered as expected
            Assert.Equal("address", result[0]);
            Assert.Equal("hasHeaders", result[1]);
        }