public void GetRequestBodyDocForOperation() { var builder = new MetaDataObjectBuilder(_serviceDefinition); var checkAvailabilityPostOperation = _serviceDefinition.Paths["/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"]["post"]; var requestBody = builder.GetRequestBodyForOperation(checkAvailabilityPostOperation, true); Assert.NotNull(requestBody); Assert.Equal(2, requestBody.Count); Assert.Equal("\"name\": \"The storage account name.\"", requestBody.First.ToString()); Assert.Equal("\"type\": \"The type of resource, Microsoft.Storage/storageAccounts\"", requestBody.Last.ToString()); }
public void GetRequestBodyDocForOperation() { var builder = new MetaDataObjectBuilder(_serviceDefinition); var putRouteTableOperation = _serviceDefinition.Paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}"]["put"]; var requestBodyDoc = builder.GetRequestBodyForOperation(putRouteTableOperation, true); Assert.NotNull(requestBodyDoc); Assert.Equal(7, requestBodyDoc.Count); Assert.Equal("Resource ID.", requestBodyDoc.GetValue("id").ToString()); Assert.Equal("Resource name.", requestBodyDoc.GetValue("name")); Assert.Equal("Resource type.", requestBodyDoc.GetValue("type")); Assert.Equal("Resource location.", requestBodyDoc.GetValue("location")); Assert.False(requestBodyDoc.GetValue("tags").HasValues); Assert.Equal("Gets a unique read-only string that changes whenever the resource is updated.", requestBodyDoc.GetValue("etag")); }
public void GetRequestBodyForOperation() { var builder = new MetaDataObjectBuilder(_serviceDefinition); var putRouteTableOperation = _serviceDefinition.Paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}"]["put"]; var requestBody = builder.GetRequestBodyForOperation(putRouteTableOperation, false); Assert.NotNull(requestBody); Assert.Equal(7, requestBody.Count); Assert.Equal("(String)", requestBody.GetValue("id")); Assert.Equal("(String)", requestBody.GetValue("name")); Assert.Equal("(String)", requestBody.GetValue("type")); Assert.Equal("(String)", requestBody.GetValue("location")); Assert.False(requestBody.GetValue("tags").HasValues); Assert.Equal("(String)", requestBody.GetValue("etag")); var propertiesKey = requestBody.GetValue("properties"); Assert.Equal("properties", propertiesKey.Path); Assert.Equal(3, propertiesKey.Children().Count()); Assert.Equal("properties.routes", propertiesKey.First.Path); Assert.Equal(JTokenType.Array, propertiesKey.First.First.Type); Assert.Equal("properties.routes[0].id", propertiesKey.First.First.First.First.Path); Assert.Equal("properties.provisioningState", propertiesKey.Last.Path); }