@@ -12,12 +12,6 @@ public sealed class ServiceBusBuilder : ContainerBuilder<ServiceBusBuilder, Serv
1212
1313 public const ushort ServiceBusPort = 5672 ;
1414
15- private const string AcceptLicenseAgreementEnvVar = "ACCEPT_EULA" ;
16-
17- private const string AcceptLicenseAgreement = "Y" ;
18-
19- private const string DeclineLicenseAgreement = "N" ;
20-
2115 /// <summary>
2216 /// Initializes a new instance of the <see cref="ServiceBusBuilder" /> class.
2317 /// </summary>
@@ -40,6 +34,15 @@ private ServiceBusBuilder(ServiceBusConfiguration resourceConfiguration)
4034 /// <inheritdoc />
4135 protected override ServiceBusConfiguration DockerResourceConfiguration { get ; }
4236
37+ /// <inheritdoc />
38+ protected override string AcceptLicenseAgreementEnvVar { get ; } = "ACCEPT_EULA" ;
39+
40+ /// <inheritdoc />
41+ protected override string AcceptLicenseAgreement { get ; } = "Y" ;
42+
43+ /// <inheritdoc />
44+ protected override string DeclineLicenseAgreement { get ; } = "N" ;
45+
4346 /// <summary>
4447 /// Accepts the license agreement.
4548 /// </summary>
@@ -48,7 +51,7 @@ private ServiceBusBuilder(ServiceBusConfiguration resourceConfiguration)
4851 /// </remarks>
4952 /// <param name="acceptLicenseAgreement">A boolean value indicating whether the Azure Service Bus Emulator license agreement is accepted.</param>
5053 /// <returns>A configured instance of <see cref="ServiceBusBuilder" />.</returns>
51- public ServiceBusBuilder WithAcceptLicenseAgreement ( bool acceptLicenseAgreement )
54+ public override ServiceBusBuilder WithAcceptLicenseAgreement ( bool acceptLicenseAgreement )
5255 {
5356 var licenseAgreement = acceptLicenseAgreement ? AcceptLicenseAgreement : DeclineLicenseAgreement ;
5457 return WithEnvironment ( AcceptLicenseAgreementEnvVar , licenseAgreement ) ;
@@ -85,6 +88,7 @@ public ServiceBusBuilder WithMsSqlContainer(
8588 public override ServiceBusContainer Build ( )
8689 {
8790 Validate ( ) ;
91+ ValidateLicenseAgreement ( ) ;
8892
8993 if ( DockerResourceConfiguration . DatabaseContainer != null )
9094 {
@@ -105,20 +109,6 @@ public override ServiceBusContainer Build()
105109 return new ServiceBusContainer ( serviceBusContainer . DockerResourceConfiguration ) ;
106110 }
107111
108- /// <inheritdoc />
109- protected override void Validate ( )
110- {
111- const string message = "The image '{0}' requires you to accept a license agreement." ;
112-
113- base . Validate ( ) ;
114-
115- Predicate < ServiceBusConfiguration > licenseAgreementNotAccepted = value =>
116- ! value . Environments . TryGetValue ( AcceptLicenseAgreementEnvVar , out var licenseAgreementValue ) || ! AcceptLicenseAgreement . Equals ( licenseAgreementValue , StringComparison . Ordinal ) ;
117-
118- _ = Guard . Argument ( DockerResourceConfiguration , nameof ( DockerResourceConfiguration . Image ) )
119- . ThrowIf ( argument => licenseAgreementNotAccepted ( argument . Value ) , argument => throw new ArgumentException ( string . Format ( message , DockerResourceConfiguration . Image . FullName ) , argument . Name ) ) ;
120- }
121-
122112 /// <inheritdoc />
123113 protected override ServiceBusBuilder Init ( )
124114 {
0 commit comments