< Summary

Class:Microsoft.Azure.Search.Tests.Utilities.SearchTestBase`1
Assembly:Search.Management.Tests
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\Utilities\SearchTestBase.cs
Covered lines:10
Uncovered lines:3
Coverable lines:13
Total lines:50
Line coverage:76.9% (10 of 13)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Data()-100%100%
GetSearchManagementClient()-0%0%
Run(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\Utilities\SearchTestBase.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.Search.Tests.Utilities
 6{
 7    using System;
 8    using System.Runtime.CompilerServices;
 9    using Microsoft.Azure.Management.Search;
 10    using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
 11
 12    public abstract class SearchTestBase<TTestFixture> : TestBase where TTestFixture : IResourceFixture, new()
 13    {
 14        private MockContext _currentContext; // Changes as each test runs.
 15
 266616        protected TTestFixture Data { get; private set; }
 17
 18        protected SearchManagementClient GetSearchManagementClient()
 19        {
 020            if (_currentContext == null)
 21            {
 022                throw new InvalidOperationException("GetSearchManagementClient() can only be called from a running test.
 23            }
 24
 025            return _currentContext.GetServiceClient<SearchManagementClient>();
 26        }
 27
 28        protected void Run(
 29            Action testBody,
 30            [CallerMemberName]
 31            string methodName = "unknown_caller")
 32        {
 60233            using (var mockContext = MockContext.Start(this.GetType(), methodName))
 34            {
 60235                _currentContext = mockContext;
 60236                Data = new TTestFixture();
 60237                Data.Initialize(mockContext);
 38
 39                try
 40                {
 60241                    testBody();
 60242                }
 43                finally
 44                {
 60245                    Data.Cleanup();
 60246                }
 47            }
 60248        }
 49    }
 50}