@@ -14,12 +14,6 @@ public sealed class Db2Builder : ContainerBuilder<Db2Builder, Db2Container, Db2C
14
14
15
15
public const string DefaultPassword = "db2inst1" ;
16
16
17
- private const string AcceptLicenseAgreementEnvVar = "LICENSE" ;
18
-
19
- private const string AcceptLicenseAgreement = "accept" ;
20
-
21
- private const string DeclineLicenseAgreement = "decline" ;
22
-
23
17
/// <summary>
24
18
/// Initializes a new instance of the <see cref="Db2Builder" /> class.
25
19
/// </summary>
@@ -42,6 +36,15 @@ private Db2Builder(Db2Configuration resourceConfiguration)
42
36
/// <inheritdoc />
43
37
protected override Db2Configuration DockerResourceConfiguration { get ; }
44
38
39
+ /// <inheritdoc />
40
+ protected override string AcceptLicenseAgreementEnvVar { get ; } = "LICENSE" ;
41
+
42
+ /// <inheritdoc />
43
+ protected override string AcceptLicenseAgreement { get ; } = "accept" ;
44
+
45
+ /// <inheritdoc />
46
+ protected override string DeclineLicenseAgreement { get ; } = "decline" ;
47
+
45
48
/// <summary>
46
49
/// Accepts the license agreement.
47
50
/// </summary>
@@ -50,7 +53,7 @@ private Db2Builder(Db2Configuration resourceConfiguration)
50
53
/// </remarks>
51
54
/// <param name="acceptLicenseAgreement">A boolean value indicating whether the Db2 license agreement is accepted.</param>
52
55
/// <returns>A configured instance of <see cref="Db2Builder" />.</returns>
53
- public Db2Builder WithAcceptLicenseAgreement ( bool acceptLicenseAgreement )
56
+ public override Db2Builder WithAcceptLicenseAgreement ( bool acceptLicenseAgreement )
54
57
{
55
58
var licenseAgreement = acceptLicenseAgreement ? AcceptLicenseAgreement : DeclineLicenseAgreement ;
56
59
return WithEnvironment ( AcceptLicenseAgreementEnvVar , licenseAgreement ) ;
@@ -94,6 +97,7 @@ public Db2Builder WithPassword(string password)
94
97
public override Db2Container Build ( )
95
98
{
96
99
Validate ( ) ;
100
+ ValidateLicenseAgreement ( ) ;
97
101
return new Db2Container ( DockerResourceConfiguration ) ;
98
102
}
99
103
@@ -110,16 +114,8 @@ protected override Db2Builder Init() => base.Init()
110
114
/// <inheritdoc />
111
115
protected override void Validate ( )
112
116
{
113
- const string message = "The image '{0}' requires you to accept a license agreement." ;
114
-
115
117
base . Validate ( ) ;
116
118
117
- Predicate < Db2Configuration > licenseAgreementNotAccepted = value =>
118
- ! value . Environments . TryGetValue ( AcceptLicenseAgreementEnvVar , out var licenseAgreementValue ) || ! AcceptLicenseAgreement . Equals ( licenseAgreementValue , StringComparison . Ordinal ) ;
119
-
120
- _ = Guard . Argument ( DockerResourceConfiguration , nameof ( DockerResourceConfiguration . Image ) )
121
- . ThrowIf ( argument => licenseAgreementNotAccepted ( argument . Value ) , argument => throw new ArgumentException ( string . Format ( message , DockerResourceConfiguration . Image . FullName ) , argument . Name ) ) ;
122
-
123
119
_ = Guard . Argument ( DockerResourceConfiguration . Username , nameof ( DockerResourceConfiguration . Username ) )
124
120
. NotNull ( )
125
121
. NotEmpty ( ) ;
0 commit comments