< Summary

Class:Microsoft.Azure.Management.Search.Tests.AdminKeyTests
Assembly:Search.Management.Tests
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\Tests\AdminKeyTests.cs
Covered lines:0
Uncovered lines:37
Coverable lines:37
Total lines:58
Line coverage:0% (0 of 37)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CanGetAdminKeys()-0%100%
CanRegenerateAdminKeys()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\Tests\AdminKeyTests.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Management.Search.Tests
 6{
 7    using Microsoft.Azure.Management.Search.Models;
 8    using Microsoft.Azure.Search.Tests.Utilities;
 9    using Xunit;
 10
 11    public sealed class AdminKeyTests : SearchTestBase<SearchServiceFixture>
 12    {
 13        [Fact]
 14        public void CanGetAdminKeys()
 15        {
 016            Run(() =>
 017            {
 018                SearchManagementClient searchMgmt = GetSearchManagementClient();
 019
 020                // List admin keys
 021                AdminKeyResult adminKeyResult =
 022                    searchMgmt.AdminKeys.Get(Data.ResourceGroupName, Data.SearchServiceName);
 023
 024                Assert.NotNull(adminKeyResult);
 025                Assert.NotNull(adminKeyResult.PrimaryKey);
 026                Assert.NotNull(adminKeyResult.SecondaryKey);
 027                Assert.NotEmpty(adminKeyResult.PrimaryKey);
 028                Assert.NotEmpty(adminKeyResult.SecondaryKey);
 029            });
 030        }
 31
 32        [Fact]
 33        public void CanRegenerateAdminKeys()
 34        {
 035            Run(() =>
 036            {
 037                SearchManagementClient searchMgmt = GetSearchManagementClient();
 038
 039                AdminKeyResult originalAdminKeys =
 040                    searchMgmt.AdminKeys.Get(Data.ResourceGroupName, Data.SearchServiceName);
 041
 042                AdminKeyResult keysWithNewPrimary =
 043                    searchMgmt.AdminKeys.Regenerate(Data.ResourceGroupName, Data.SearchServiceName, AdminKeyKind.Primary
 044
 045                Assert.False(string.IsNullOrEmpty(keysWithNewPrimary.PrimaryKey));
 046                Assert.NotEqual(originalAdminKeys.PrimaryKey, keysWithNewPrimary.PrimaryKey);
 047                Assert.Equal(originalAdminKeys.SecondaryKey, keysWithNewPrimary.SecondaryKey);
 048
 049                AdminKeyResult keysWithNewSecondary =
 050                    searchMgmt.AdminKeys.Regenerate(Data.ResourceGroupName, Data.SearchServiceName, AdminKeyKind.Seconda
 051
 052                Assert.False(string.IsNullOrEmpty(keysWithNewSecondary.SecondaryKey));
 053                Assert.Equal(keysWithNewPrimary.PrimaryKey, keysWithNewSecondary.PrimaryKey);
 054                Assert.NotEqual(keysWithNewPrimary.SecondaryKey, keysWithNewSecondary.SecondaryKey);
 055            });
 056        }
 57    }
 58}