@@ -84,9 +84,9 @@ public void Baggage()
8484 Assert . Equal ( "world" , anotherActivity . GetBaggageItem ( "hello" ) ) ;
8585 Assert . Equal ( 4 , anotherActivity . Baggage . Count ( ) ) ;
8686 Assert . Equal ( new KeyValuePair < string , string > ( "hello" , "world" ) , anotherActivity . Baggage . First ( ) ) ;
87- Assert . Equal ( new KeyValuePair < string , string > ( Key + 0 , Value + 0 ) , anotherActivity . Baggage . Skip ( 1 ) . First ( ) ) ;
87+ Assert . Equal ( new KeyValuePair < string , string > ( Key + 2 , Value + 2 ) , anotherActivity . Baggage . Skip ( 1 ) . First ( ) ) ;
8888 Assert . Equal ( new KeyValuePair < string , string > ( Key + 1 , Value + 1 ) , anotherActivity . Baggage . Skip ( 2 ) . First ( ) ) ;
89- Assert . Equal ( new KeyValuePair < string , string > ( Key + 2 , Value + 2 ) , anotherActivity . Baggage . Skip ( 3 ) . First ( ) ) ;
89+ Assert . Equal ( new KeyValuePair < string , string > ( Key + 0 , Value + 0 ) , anotherActivity . Baggage . Skip ( 3 ) . First ( ) ) ;
9090 }
9191 finally
9292 {
@@ -99,6 +99,69 @@ public void Baggage()
9999 }
100100 }
101101
102+ [ Fact ]
103+ public void TestBaggageOrderAndDuplicateKeys ( )
104+ {
105+ Activity a = new Activity ( "Baggage" ) ;
106+ a . AddBaggage ( "1" , "1" ) ;
107+ a . AddBaggage ( "1" , "2" ) ;
108+ a . AddBaggage ( "1" , "3" ) ;
109+ a . AddBaggage ( "1" , "4" ) ;
110+
111+ int value = 4 ;
112+
113+ foreach ( KeyValuePair < string , string > kvp in a . Baggage )
114+ {
115+ Assert . Equal ( "1" , kvp . Key ) ;
116+ Assert . Equal ( value . ToString ( ) , kvp . Value ) ;
117+ value -- ;
118+ }
119+
120+ Assert . Equal ( "4" , a . GetBaggageItem ( "1" ) ) ;
121+ }
122+
123+ [ ConditionalFact ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
124+ public void TestBaggageWithChainedActivities ( )
125+ {
126+ RemoteExecutor . Invoke ( ( ) => {
127+ Activity a1 = new Activity ( "a1" ) ;
128+ a1 . Start ( ) ;
129+
130+ a1 . AddBaggage ( "1" , "1" ) ;
131+ a1 . AddBaggage ( "2" , "2" ) ;
132+
133+ IEnumerable < KeyValuePair < string , string > > baggages = a1 . Baggage ;
134+ Assert . Equal ( 2 , baggages . Count ( ) ) ;
135+ Assert . Equal ( new KeyValuePair < string , string > ( "2" , "2" ) , baggages . ElementAt ( 0 ) ) ;
136+ Assert . Equal ( new KeyValuePair < string , string > ( "1" , "1" ) , baggages . ElementAt ( 1 ) ) ;
137+
138+ Activity a2 = new Activity ( "a2" ) ;
139+ a2 . Start ( ) ;
140+
141+ a2 . AddBaggage ( "3" , "3" ) ;
142+ baggages = a2 . Baggage ;
143+ Assert . Equal ( 3 , baggages . Count ( ) ) ;
144+ Assert . Equal ( new KeyValuePair < string , string > ( "3" , "3" ) , baggages . ElementAt ( 0 ) ) ;
145+ Assert . Equal ( new KeyValuePair < string , string > ( "2" , "2" ) , baggages . ElementAt ( 1 ) ) ;
146+ Assert . Equal ( new KeyValuePair < string , string > ( "1" , "1" ) , baggages . ElementAt ( 2 ) ) ;
147+
148+ Activity a3 = new Activity ( "a3" ) ;
149+ a3 . Start ( ) ;
150+
151+ a3 . AddBaggage ( "4" , "4" ) ;
152+ baggages = a3 . Baggage ;
153+ Assert . Equal ( 4 , baggages . Count ( ) ) ;
154+ Assert . Equal ( new KeyValuePair < string , string > ( "4" , "4" ) , baggages . ElementAt ( 0 ) ) ;
155+ Assert . Equal ( new KeyValuePair < string , string > ( "3" , "3" ) , baggages . ElementAt ( 1 ) ) ;
156+ Assert . Equal ( new KeyValuePair < string , string > ( "2" , "2" ) , baggages . ElementAt ( 2 ) ) ;
157+ Assert . Equal ( new KeyValuePair < string , string > ( "1" , "1" ) , baggages . ElementAt ( 3 ) ) ;
158+
159+ a3 . Dispose ( ) ;
160+ a2 . Dispose ( ) ;
161+ a1 . Dispose ( ) ;
162+ } ) . Dispose ( ) ;
163+ }
164+
102165 /// <summary>
103166 /// Tests Tags operations
104167 /// </summary>
0 commit comments