public void creates_postman_collection() { // Arrange var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase); var assemblyFilePath = codeBase.LocalPath; var generator = new CollectionGenerator(); // Act var actual = generator.Create(assemblyFilePath, Resources.DefaultEnvironmentKey, Resources.DefaultRouteTemplate); // Assert var jsonSerializer = new JsonSerializer() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; Debug.WriteLine(JObject.FromObject(actual, jsonSerializer).ToString()); actual.Should().NotBeNull(); actual.Requests.Count.Should().Be(_requestCount); actual.Folders.Count.Should().Be(_folderCount); actual.Description.Should().NotBeNull(); }
/// <summary> /// Builds a Postman collection from an assembly XML documentation file and writes the result to a json file. /// </summary> /// <returns></returns> public override bool Execute() { Condition.Requires(AssemblyFilePath).IsNotNullOrEmpty(); Condition.Requires(OutputDirectory).IsNotNullOrEmpty(); Condition.Requires(EnvironmentKey).IsNotNullOrEmpty(); LogMessage(Resources.GeneratingPostmanCollection, AssemblyFilePath); var generator = new CollectionGenerator(); var collection = generator.Create(AssemblyFilePath, EnvironmentKey, RouteTemplate); if (!collection.Folders.Any()) { LogWarning(Resources.NoApiControllerClassesFound); } WriteFile(collection, OutputFilePath); LogMessage(Resources.PostmanCollectionCreated, OutputFilePath); return true; }