@@ -135,6 +135,102 @@ public void NewAzureBgpPeeringSuccessful()
135
135
Assert . Equal ( expectedBgp . BgpPeering . PrimaryAzurePort , actual . PrimaryAzurePort ) ;
136
136
}
137
137
138
+ [ Fact ]
139
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
140
+ public void NewAzureMicrosoftBgpPeeringSuccessful ( )
141
+ {
142
+ // Setup
143
+ string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead" ;
144
+ UInt32 peerAsn = 64496 ;
145
+ string primaryPeerSubnet = "aaa" ;
146
+ string secondayPeerSubnet = "bbb" ;
147
+ UInt32 azureAsn = 64494 ;
148
+ string primaryAzurePort = "8081" ;
149
+ string secondaryAzurePort = "8082" ;
150
+ var state = BgpPeeringState . Enabled ;
151
+ uint vlanId = 2 ;
152
+ var accessType = BgpPeeringAccessType . Microsoft ;
153
+ uint legacyMode = 0 ;
154
+ string prefix = "12.2.3.4/30" ;
155
+
156
+ MockCommandRuntime mockCommandRuntime = new MockCommandRuntime ( ) ;
157
+ Mock < ExpressRouteManagementClient > client = InitExpressRouteManagementClient ( ) ;
158
+ var bgpMock = new Mock < IBorderGatewayProtocolPeeringOperations > ( ) ;
159
+
160
+ BorderGatewayProtocolPeeringGetResponse expectedBgp =
161
+ new BorderGatewayProtocolPeeringGetResponse
162
+ {
163
+ BgpPeering = new AzureBgpPeering ( )
164
+ {
165
+ AzureAsn = azureAsn ,
166
+ PeerAsn = peerAsn ,
167
+ PrimaryAzurePort = primaryAzurePort ,
168
+ PrimaryPeerSubnet = primaryPeerSubnet ,
169
+ SecondaryAzurePort = secondaryAzurePort ,
170
+ SecondaryPeerSubnet = secondayPeerSubnet ,
171
+ State = state ,
172
+ VlanId = vlanId ,
173
+ LegacyMode = legacyMode ,
174
+ AdvertisedPublicPrefixes = prefix
175
+ } ,
176
+ RequestId = "" ,
177
+ StatusCode = new HttpStatusCode ( )
178
+ } ;
179
+
180
+ ExpressRouteOperationStatusResponse expectedStatus = new ExpressRouteOperationStatusResponse ( )
181
+ {
182
+ HttpStatusCode = HttpStatusCode . OK
183
+ } ;
184
+
185
+ var tGet = new Task < BorderGatewayProtocolPeeringGetResponse > ( ( ) => expectedBgp ) ;
186
+ tGet . Start ( ) ;
187
+
188
+ var tNew = new Task < ExpressRouteOperationStatusResponse > ( ( ) => expectedStatus ) ;
189
+ tNew . Start ( ) ;
190
+
191
+ bgpMock . Setup (
192
+ f =>
193
+ f . NewAsync ( It . Is < string > ( x => x == serviceKey ) ,
194
+ It . Is < BgpPeeringAccessType > (
195
+ y => y == accessType ) ,
196
+ It . Is < BorderGatewayProtocolPeeringNewParameters > (
197
+ z =>
198
+ z . PeerAutonomousSystemNumber == peerAsn && z . PrimaryPeerSubnet == primaryPeerSubnet &&
199
+ z . SecondaryPeerSubnet == secondayPeerSubnet && z . VirtualLanId == vlanId ) ,
200
+ It . IsAny < CancellationToken > ( ) ) )
201
+ . Returns ( ( string sKey , BgpPeeringAccessType atype , BorderGatewayProtocolPeeringNewParameters param , CancellationToken cancellation ) => tNew ) ;
202
+ client . SetupGet ( f => f . BorderGatewayProtocolPeerings ) . Returns ( bgpMock . Object ) ;
203
+
204
+ bgpMock . Setup (
205
+ f =>
206
+ f . GetAsync ( It . Is < string > ( x => x == serviceKey ) ,
207
+ It . Is < BgpPeeringAccessType > (
208
+ y => y == accessType ) ,
209
+ It . IsAny < CancellationToken > ( ) ) )
210
+ . Returns ( ( string sKey , BgpPeeringAccessType atype , CancellationToken cancellation ) => tGet ) ;
211
+ client . SetupGet ( f => f . BorderGatewayProtocolPeerings ) . Returns ( bgpMock . Object ) ;
212
+
213
+ NewAzureBGPPeeringCommand cmdlet = new NewAzureBGPPeeringCommand ( )
214
+ {
215
+ ServiceKey = Guid . Parse ( serviceKey ) ,
216
+ AccessType = accessType ,
217
+ PeerAsn = peerAsn ,
218
+ PrimaryPeerSubnet = primaryPeerSubnet ,
219
+ SecondaryPeerSubnet = secondayPeerSubnet ,
220
+ SharedKey = null ,
221
+ VlanId = vlanId ,
222
+ CommandRuntime = mockCommandRuntime ,
223
+ ExpressRouteClient = new ExpressRouteClient ( client . Object )
224
+ } ;
225
+
226
+ cmdlet . ExecuteCmdlet ( ) ;
227
+
228
+ // Assert
229
+ AzureBgpPeering actual = mockCommandRuntime . OutputPipeline [ 0 ] as AzureBgpPeering ;
230
+ Assert . Equal ( expectedBgp . BgpPeering . State , actual . State ) ;
231
+ Assert . Equal ( expectedBgp . BgpPeering . PrimaryAzurePort , actual . PrimaryAzurePort ) ;
232
+ }
233
+
138
234
[ Fact ]
139
235
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
140
236
public void GetAzureBgpPeeringSuccessful ( )
0 commit comments