-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create NSwagStudioCodeGenerator tests with mock data
- Loading branch information
1 parent
b02737b
commit e41729d
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/ApiClientCodeGen.Tests/Generators/NSwagStudio/NSwagStudioCodeGeneratorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.IO; | ||
using ChristianHelle.DeveloperTools.CodeGenerators.ApiClient.Core; | ||
using ChristianHelle.DeveloperTools.CodeGenerators.ApiClient.Core.Generators; | ||
using ChristianHelle.DeveloperTools.CodeGenerators.ApiClient.Core.Generators.NSwagStudio; | ||
using ChristianHelle.DeveloperTools.CodeGenerators.ApiClient.Core.Options.General; | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
|
||
namespace ChristianHelle.DeveloperTools.CodeGenerators.ApiClient.Tests.Generators.NSwagStudio | ||
{ | ||
[TestClass] | ||
[TestCategory("SkipWhenLiveUnitTesting")] | ||
[DeploymentItem("Resources/Swagger.nswag")] | ||
[DeploymentItem("Resources/Swagger.json")] | ||
public class NSwagStudioCodeGeneratorTests | ||
{ | ||
private Mock<IGeneralOptions> optionsMock; | ||
private Mock<IProcessLauncher> processMock; | ||
private Mock<IProgressReporter> progressMock; | ||
private IGeneralOptions options; | ||
|
||
[TestInitialize] | ||
public void Init() | ||
{ | ||
optionsMock = new Mock<IGeneralOptions>(); | ||
optionsMock.Setup(c => c.NSwagPath).Returns(Path.GetTempFileName()); | ||
options = optionsMock.Object; | ||
|
||
processMock = new Mock<IProcessLauncher>(); | ||
progressMock = new Mock<IProgressReporter>(); | ||
} | ||
|
||
[TestMethod] | ||
public void NSwagStudio_Generate_Code_Using_NSwagStudio() | ||
=> new NSwagStudioCodeGenerator(Path.GetFullPath("Swagger.nswag"), options, processMock.Object) | ||
.GenerateCode(progressMock.Object) | ||
.Should() | ||
.BeNull(); | ||
|
||
[TestMethod] | ||
public void Reads_NSwagPath_From_Options() | ||
{ | ||
progressMock = new Mock<IProgressReporter>(); | ||
new NSwagStudioCodeGenerator( | ||
Path.GetFullPath("Swagger.nswag"), | ||
options, | ||
processMock.Object) | ||
.GenerateCode(progressMock.Object); | ||
|
||
optionsMock.Verify(c => c.NSwagPath); | ||
} | ||
} | ||
} |