-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClimateApiRecordingTests.cs
94 lines (85 loc) · 3.97 KB
/
ClimateApiRecordingTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using Microsoft.Extensions.Logging;
using Servirtium.AspNetCore;
using Servirtium.Core;
using Servirtium.Core.Http;
using Servirtium.Core.Interactions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Xunit;
using static Servirtium.Climate.Demo.TestDirectories;
namespace Servirtium.Climate.Demo
{
[Xunit.Collection("Servirtium ClimateApi Demo")]
[CollectionDefinition(nameof(ClimateApiRecordingTests), DisableParallelization = true)]
public class ClimateApiRecordingTests : ClimateApiTests
{
internal override IEnumerable<(IServirtiumServer, ClimateApi)> GenerateTestServerClientPairs(string script)
{
var recorder = new InteractionRecorder(
ClimateApi.GetRealServiceUrl(), Path.Combine(RECORDING_OUTPUT_DIRECTORY, script),
new FindAndReplaceScriptWriter(new[] {
new RegexReplacement(new Regex("Set-Cookie: AWSALB=.*"), "Set-Cookie: AWSALB=REPLACED-IN-RECORDING; Expires=Thu, 15 Jan 2099 11:11:11 GMT; Path=/"),
new RegexReplacement(new Regex("Set-Cookie: TS0137860d=.*"), "Set-Cookie: TS0137860d=ALSO-REPLACED-IN-RECORDING; Path=/"),
new RegexReplacement(new Regex("Set-Cookie: TS01c35ec3=.*"), "Set-Cookie: TS01c35ec3=ONE-MORE-REPLACED-IN-RECORDING; Path=/"),
new RegexReplacement(new Regex("Set-Cookie: climatedataapi.cookie=.*"), "Set-Cookie: climatedataapi.cookie=1234567899999; Path=/"),
new RegexReplacement(new Regex("Set-Cookie: climatedataapi_ext.cookie=.*"), "Set-Cookie: climatedataapi_ext.cookie=9876543211111; Path=/"),
new RegexReplacement(new Regex("User-Agent: .*"), "User-Agent: Servirtium-Testing")
}, new MarkdownScriptWriter(null, loggerFactory), loggerFactory), loggerFactory);
yield return
(
AspNetCoreServirtiumServer.WithTransforms(
61417,
recorder,
new SimpleHttpMessageTransforms(
ClimateApi.GetRealServiceUrl(),
new Regex[0],
new[] {
"Date:", "X-", "Strict-Transport-Security",
"Content-Security-Policy", "Cache-Control", "Secure", "HttpOnly",
"Set-Cookie: climatedata.cookie=" }.Select(pattern => new Regex(pattern)),
loggerFactory
), loggerFactory),
new ClimateApi(ClimateApi.GetRealServiceUrl())
);
}
[Fact]
public override void AverageRainfallForGreatBritainFrom1980to1999Exists()
{
base.AverageRainfallForGreatBritainFrom1980to1999Exists();
}
[Fact]
public override void AverageRainfallForFranceFrom1980to1999Exists()
{
base.AverageRainfallForFranceFrom1980to1999Exists();
}
[Fact]
public override void AverageRainfallForEgyptFrom1980to1999Exists()
{
base.AverageRainfallForEgyptFrom1980to1999Exists();
}
[Fact]
public override void AverageRainfallForGreatBritainFrom1985to1995DoesNotExist()
{
base.AverageRainfallForGreatBritainFrom1985to1995DoesNotExist();
}
[Fact]
public override void AverageRainfallForMiddleEarthFrom1980to1999DoesNotExist()
{
base.AverageRainfallForMiddleEarthFrom1980to1999DoesNotExist();
}
[Fact]
public override void AverageRainfallForGreatBritainAndFranceFrom1980to1999CanBeCalculatedFromTwoRequests()
{
base.AverageRainfallForGreatBritainAndFranceFrom1980to1999CanBeCalculatedFromTwoRequests();
}
[Fact]
public override void AverageRainfallForNeptuneServiceNotFound()
{
base.AverageRainfallForNeptuneServiceNotFound();
}
}
}