|
| 1 | +using Xunit; |
| 2 | +using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common; |
| 3 | +using System; |
| 4 | +using System.IO; |
| 5 | +using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Create; |
| 6 | + |
| 7 | +namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Test |
| 8 | +{ |
| 9 | + public class FileReaderTests |
| 10 | + { |
| 11 | + [Fact] |
| 12 | + public async void ShouldConvertYAMLConfigToCreatorConfiguration() |
| 13 | + { |
| 14 | + // arrange |
| 15 | + FileReader fileReader = new FileReader(); |
| 16 | + string fileLocation = String.Concat("..", Path.DirectorySeparatorChar, |
| 17 | + "..", Path.DirectorySeparatorChar, |
| 18 | + "..", Path.DirectorySeparatorChar, |
| 19 | + "..", Path.DirectorySeparatorChar, |
| 20 | + "apimtemplate", Path.DirectorySeparatorChar, |
| 21 | + "Creator", Path.DirectorySeparatorChar, |
| 22 | + "ExampleFiles", Path.DirectorySeparatorChar, |
| 23 | + "YAMLConfigs", Path.DirectorySeparatorChar, "valid.yml"); |
| 24 | + |
| 25 | + // act |
| 26 | + CreatorConfig creatorConfig = await fileReader.ConvertConfigYAMLToCreatorConfigAsync(fileLocation); |
| 27 | + |
| 28 | + // assert |
| 29 | + Assert.Equal("0.0.1", creatorConfig.version); |
| 30 | + Assert.Equal("myAPIMService", creatorConfig.apimServiceName); |
| 31 | + Assert.Equal(@"C:\Users\myUsername\GeneratedTemplates", creatorConfig.outputLocation); |
| 32 | + Assert.Equal("myAPI", creatorConfig.apis[0].name); |
| 33 | + } |
| 34 | + |
| 35 | + [Fact] |
| 36 | + public async void ShouldRetrieveFileContentsWithoutError() |
| 37 | + { |
| 38 | + // arrange |
| 39 | + FileReader fileReader = new FileReader(); |
| 40 | + string fileLocation = "https://petstore.swagger.io/v2/swagger.json"; |
| 41 | + |
| 42 | + // act |
| 43 | + try |
| 44 | + { |
| 45 | + var content = await fileReader.RetrieveFileContentsAsync(fileLocation); |
| 46 | + // assert |
| 47 | + Assert.True(true); |
| 48 | + } |
| 49 | + catch (Exception ex) |
| 50 | + { |
| 51 | + // assert |
| 52 | + Assert.NotNull(ex); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments