@@ -104,37 +104,75 @@ public sealed class EqualTest
104104 {
105105 [ Fact ]
106106 [ Trait ( nameof ( DockerCli . DockerPlatform ) , nameof ( DockerCli . DockerPlatform . Linux ) ) ]
107- public void ForSameConfigurationCreatedInDifferentOrder ( )
107+ public void ForKnownConfiguration ( )
108108 {
109- var env1 = new Dictionary < string , string >
110- {
111- [ "keyA" ] = "valueA" ,
112- [ "keyB" ] = "valueB" ,
113- } ;
114- var env2 = new Dictionary < string , string >
115- {
116- [ "keyB" ] = "valueB" ,
117- [ "keyA" ] = "valueA" ,
118- } ;
119- var hash1 = new ReuseHashContainerBuilder ( ) . WithEnvironment ( env1 ) . WithLabel ( "labelA" , "A" ) . WithLabel ( "labelB" , "B" ) . GetReuseHash ( ) ;
120- var hash2 = new ReuseHashContainerBuilder ( ) . WithEnvironment ( env2 ) . WithLabel ( "labelB" , "B" ) . WithLabel ( "labelA" , "A" ) . GetReuseHash ( ) ;
121- Assert . Equal ( hash1 , hash2 ) ;
109+ // Given
110+ var env = new Dictionary < string , string > ( ) ;
111+ env [ "keyA" ] = "valueA" ;
112+ env [ "keyB" ] = "valueB" ;
113+
114+ // When
115+ var hash = new ReuseHashContainerBuilder ( )
116+ . WithEnvironment ( env )
117+ . WithLabel ( "labelA" , "A" )
118+ . WithLabel ( "labelB" , "B" )
119+ . GetReuseHash ( ) ;
120+
121+ // Then
122+
123+ // `50MEP+vnxEkQFo5PrndJ7oKOfh8=` is the Base64-encoded SHA-1 hash of this JSON:
124+ //
125+ // {
126+ // "Image": null,
127+ // "Name": null,
128+ // "Entrypoint": null,
129+ // "Command": [],
130+ // "Environments": {
131+ // "keyA": "valueA",
132+ // "keyB": "valueB"
133+ // },
134+ // "ExposedPorts": {},
135+ // "PortBindings": {},
136+ // "NetworkAliases": [],
137+ // "ExtraHosts": [],
138+ // "Labels": {
139+ // "labelA": "A",
140+ // "labelB": "B",
141+ // "org.testcontainers": "true",
142+ // "org.testcontainers.lang": "dotnet"
143+ // }
144+ // }
145+ Assert . Equal ( "50MEP+vnxEkQFo5PrndJ7oKOfh8=" , hash ) ;
122146 }
123147
124148 [ Fact ]
125149 [ Trait ( nameof ( DockerCli . DockerPlatform ) , nameof ( DockerCli . DockerPlatform . Linux ) ) ]
126- public void ForGivenConfiguration ( )
150+ public void ForSameConfigurationInDifferentOrder ( )
127151 {
128- var env = new Dictionary < string , string >
129- {
130- [ "keyB" ] = "valueB" ,
131- [ "keyA" ] = "valueA" ,
132- } ;
133- var hash = new ReuseHashContainerBuilder ( ) . WithEnvironment ( env ) . WithLabel ( "labelB" , "B" ) . WithLabel ( "labelA" , "A" ) . GetReuseHash ( ) ;
134-
135- // 50MEP+vnxEkQFo5PrndJ7oKOfh8= is the base64 encoded SHA1 of this JSON:
136- // {"Image":null,"Name":null,"Entrypoint":null,"Command":[],"Environments":{"keyA":"valueA","keyB":"valueB"},"ExposedPorts":{},"PortBindings":{},"NetworkAliases":[],"ExtraHosts":[],"Labels":{"labelA":"A","labelB":"B","org.testcontainers":"true","org.testcontainers.lang":"dotnet"}}
137- Assert . Equal ( "50MEP+vnxEkQFo5PrndJ7oKOfh8=" , hash ) ;
152+ // Given
153+ var env1 = new Dictionary < string , string > ( ) ;
154+ env1 [ "keyA" ] = "valueA" ;
155+ env1 [ "keyB" ] = "valueB" ;
156+
157+ var env2 = new Dictionary < string , string > ( ) ;
158+ env2 [ "keyB" ] = "valueB" ;
159+ env2 [ "keyA" ] = "valueA" ;
160+
161+ // When
162+ var hash1 = new ReuseHashContainerBuilder ( )
163+ . WithEnvironment ( env1 )
164+ . WithLabel ( "labelA" , "A" )
165+ . WithLabel ( "labelB" , "B" )
166+ . GetReuseHash ( ) ;
167+
168+ var hash2 = new ReuseHashContainerBuilder ( )
169+ . WithEnvironment ( env2 )
170+ . WithLabel ( "labelB" , "B" )
171+ . WithLabel ( "labelA" , "A" )
172+ . GetReuseHash ( ) ;
173+
174+ // Then
175+ Assert . Equal ( hash1 , hash2 ) ;
138176 }
139177 }
140178
0 commit comments