Skip to content

Commit d5a019e

Browse files
committed
more unit tests and refactorings
1 parent 3dcecdc commit d5a019e

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/QAToolKit.Source.Swagger.Test/SwaggerFileSourceIntegrationTest.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67
using Xunit;
78

89
namespace QAToolKit.Source.Swagger.Test
910
{
1011
public class SwaggerFileSourceIntegrationTest
1112
{
1213
[Fact]
13-
public async void SwaggerFileSourceWithoutOptionsTest_Successfull()
14+
public async void SwaggerFileSourceWithOptionsTest_Successfull()
1415
{
1516
var fileSource = new SwaggerFileSource(options =>
1617
{
@@ -22,6 +23,17 @@ public async void SwaggerFileSourceWithoutOptionsTest_Successfull()
2223
});
2324

2425
Assert.NotNull(requests);
26+
Assert.Equal(19, requests.Count());
27+
}
28+
29+
[Fact]
30+
public async void SwaggerFileSourceWithoutOptionsTest_Fails()
31+
{
32+
var fileSource = new SwaggerFileSource();
33+
34+
await Assert.ThrowsAsync<Exception>(async () => await fileSource.Load(new List<FileInfo>() {
35+
new FileInfo("Assets/swagger-test.json")
36+
}));
2537
}
2638
}
2739
}

src/QAToolKit.Source.Swagger.Test/SwaggerUrlSourceIntegrationTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public async Task SwaggerUrlSourceWithOptionsV3Test_Successfull()
4646
Assert.NotNull(requests);
4747
}
4848

49+
[Fact]
50+
public async Task SwaggerUrlSourceWithoutUrlV3Test_Fails()
51+
{
52+
var urlSource = new SwaggerUrlSource();
53+
await Assert.ThrowsAsync<UriFormatException>(async () => await urlSource.Load(
54+
new Uri[]
55+
{
56+
new Uri("")
57+
}));
58+
}
4959

5060
/* [Fact]
5161
public async Task SwaggerUrlSourceWithoutOptionsV2Test_Successfull()

src/QAToolKit.Source.Swagger/SwaggerFileSource.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public async Task<IList<HttpTestRequest>> Load(IList<FileInfo> source)
3535
{
3636
if (source == null) throw new ArgumentNullException(nameof(source));
3737

38+
if (_swaggerOptions.BaseUrl == null) throw new Exception("Swagger from file source needs BaseUrl defined. If absolute URL is defined in swagger file, that one will be used.");
39+
3840
var restRequests = new List<HttpTestRequest>();
3941
var processor = new SwaggerProcessor();
4042

@@ -53,10 +55,5 @@ public async Task<IList<HttpTestRequest>> Load(IList<FileInfo> source)
5355

5456
return restRequests;
5557
}
56-
57-
internal Task Load(FileInfo fileInfo)
58-
{
59-
throw new NotImplementedException();
60-
}
6158
}
6259
}

0 commit comments

Comments
 (0)