public async void Given_UserCredential_GetCredentialsAsync_ShouldReturn_Result(string accessToken) { this._auth.SetupGet(p => p.ClientId).Returns("CLIENT_ID"); this._auth.SetupGet(p => p.UseServicePrinciple).Returns(false); this._auth.SetupGet(p => p.Username).Returns("USERNAME"); this._auth.SetupGet(p => p.Password).Returns("PASSWORD"); this._auth.SetupGet(p => p.AadInstanceUrl).Returns("https://login.microsoftonline.com/"); this._auth.SetupGet(p => p.ManagementInstanceUrl).Returns("https://management.core.windows.net/"); this._appInsights.SetupGet(p => p.SubscriptionId).Returns("SUBSCRIPTION_ID"); this._settings.SetupGet(p => p.Authentication).Returns(this._auth.Object); this._settings.SetupGet(p => p.ApplicationInsight).Returns(this._appInsights.Object); this._authResult.SetupGet(p => p.AccessToken).Returns(accessToken); this._authContext.Setup(p => p.AcquireTokenAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <UserCredential>())).ReturnsAsync(this._authResult.Object); this._service = new WebTestService(this._settings.Object, this._authContext.Object); var result = (await this._service.GetCredentialsAsync().ConfigureAwait(false)) as TokenCloudCredentials; result.Should().NotBeNull(); result.SubscriptionId.Should().BeEquivalentTo(this._appInsights.Object.SubscriptionId); result.Token.Should().BeEquivalentTo(accessToken); }
/// <summary> /// Initialises a new instance of the <see cref="WebTestServiceTest"/> class. /// </summary> /// <param name="fixture"><see cref="WebTestServiceFixture"/> instance.</param> public WebTestServiceTest(WebTestServiceFixture fixture) { this._auth = fixture.AuthenticationElement; this._appInsights = fixture.ApplicationInsightsElement; this._webTest = fixture.WebTestElement; this._webTests = fixture.WebTestElementCollection; this._settings = fixture.WebTestSettingsElement; this._authResult = fixture.AuthenticationResult; this._authContext = fixture.AuthenticationContext; this._resourceOperations = fixture.ResourceOperations; this._alertOperations = fixture.AlertOperations; this._resourceClient = fixture.ResourceManagementClient; this._insightsClient = fixture.InsightsManagementClient; this._service = fixture.WebTestService; }