Skip to content

Commit

Permalink
Create TestFramework project (#11663)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft authored Apr 30, 2020
1 parent 508d7c0 commit b9bd85c
Show file tree
Hide file tree
Showing 282 changed files with 470 additions and 412 deletions.
1 change: 1 addition & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ known_presence_issues:
- ['sdk/keyvault','#5499']
- ['sdk/eventhub','#5499']
- ['sdk/formrecognizer/Azure.AI.FormRecognizer','#5499']
- ['sdk/core/Azure.Core.TestFramework', '#5499']

# List for changelogs begins here
- ['sdk/applicationinsights/Microsoft.Azure.ApplicationInsights.Query/CHANGELOG.md','#5499']
Expand Down
3 changes: 3 additions & 0 deletions eng/Directory.Build.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<RequiredTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">netcoreapp2.1;net461</RequiredTargetFrameworks>
</PropertyGroup>

<Import Project="TestFramework.props" Condition="'$(IsTestProject)' == 'true'"/>

<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>

Expand Down Expand Up @@ -120,6 +122,7 @@
<!-- The set of tags that should be added to the packages -->
<PackageCommonTags>windowsazureofficial;azureofficial</PackageCommonTags>
<AzureCoreSharedSources>$(MSBuildThisFileDirectory)/../sdk/core/Azure.Core/src/Shared/</AzureCoreSharedSources>
<AzureCoreTestFramework>$(MSBuildThisFileDirectory)/../sdk/core/Azure.Core.TestFramework/src/Azure.Core.TestFramework.csproj</AzureCoreTestFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsSamplesProject)' == 'true'">
Expand Down
2 changes: 2 additions & 0 deletions eng/Directory.Build.Data.targets
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@

<Import Project="CodeGeneration.targets" />

<Import Project="TestFramework.targets" Condition="'$(IsTestProject)' == 'true'"/>

<!-- CentralPackageVersions properties -->
<PropertyGroup>
<CentralPackagesFile>$(MSBuildThisFileDirectory)Packages.Data.props</CentralPackagesFile>
Expand Down
6 changes: 6 additions & 0 deletions eng/TestFramework.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<!-- Support for test recordings -->
<ItemGroup>
<None Include="SessionRecords\**\*.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions eng/TestFramework.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>

<!-- Support for test recordings -->
<Target Name="UpdateSessionRecords" Condition="'$(IsTestProject)' == 'true'">
<PropertyGroup>
<SessionRecordsDirectory>SessionRecords</SessionRecordsDirectory>
</PropertyGroup>
<ItemGroup>
<_CopyItems Include="$(OutputPath)\netcoreapp2.1\SessionRecords\**\*.*" />
</ItemGroup>

<RemoveDir Directories="$(MSBuildProjectDirectory)\$(SessionRecordsDirectory)" />
<Copy
SourceFiles="@(_CopyItems)"
DestinationFolder="$(MSBuildProjectDirectory)\$(SessionRecordsDirectory)\%(RecursiveDir)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Retries="3"
RetryDelayMilliseconds="300"/>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Core.Testing;
using Azure.Core.TestFramework;

namespace Azure.Data.AppConfiguration
{
Expand All @@ -14,4 +14,4 @@ public AppConfigurationTestEnvironment() : base("appconfiguration")
public string ConnectionString => GetRecordedVariable("APPCONFIGURATION_CONNECTION_STRING");
public string Endpoint => GetRecordedVariable("APPCONFIGURATION_ENDPOINT_STRING");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(AzureCoreTestFramework)" />
<ProjectReference Include="..\..\..\identity\Azure.Identity\src\Azure.Identity.csproj" />
<ProjectReference Include="..\src\Azure.Data.AppConfiguration.csproj" />
</ItemGroup>

<Import Project="..\..\..\core\Azure.Core\tests\TestFramework.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using Newtonsoft.Json.Linq;

namespace Azure.Data.AppConfiguration.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using Azure.Core;
using Azure.Core.Testing;
using Azure.Core.TestFramework;

namespace Azure.Data.AppConfiguration.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Diagnostics;
using System.Threading.Tasks;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using System;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;
using NUnit.Framework.Constraints;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using System;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Diagnostics;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using System;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.Data.AppConfiguration.Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Threading.Tasks;
using Azure.Core.Testing;
using Azure.Core.TestFramework;
using Azure.Identity;
using NUnit.Framework;

Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core.TestFramework/Azure.Core.TestFramework.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "src\Azure.Core.TestFramework.csproj", "{961FD4FB-3CA1-4B33-B6FD-8396CF9280DF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{961FD4FB-3CA1-4B33-B6FD-8396CF9280DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{961FD4FB-3CA1-4B33-B6FD-8396CF9280DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{961FD4FB-3CA1-4B33-B6FD-8396CF9280DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{961FD4FB-3CA1-4B33-B6FD-8396CF9280DF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions sdk/core/Azure.Core.TestFramework/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsTestSupportProject>true</IsTestSupportProject>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Threading.Tasks;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class AsyncGate<TIn, TOut>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using NUnit.Framework;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
/// <summary>
/// Marks that a test should only be executed asynchronously (in a test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
internal class AsyncValidatingStream : Stream
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks);net461;net47</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="nunit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
</ItemGroup>
<!-- Import Azure.Core shared source -->
<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)EventSourceEventFormatting.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="$(AzureCoreSharedSources)ContentTypeUtilities.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
</ItemGroup>
</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Castle.DynamicProxy;
using NUnit.Framework;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
[ClientTestFixture]
public abstract class ClientTestBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class ClientTestFixtureAttribute : NUnitAttribute, IFixtureBuilder2, IPreFilter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Azure.Core.Tests;
using Castle.DynamicProxy;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class DiagnosticScopeValidatingInterceptor : IInterceptor
{
Expand Down
12 changes: 12 additions & 0 deletions sdk/core/Azure.Core.TestFramework/src/EntryRecordModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Core.TestFramework
{
public enum EntryRecordModel
{
Record,
DontRecord,
RecordWithoutRequestBody
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
/// <summary>
/// Provides values to NUnit that are public, static, read-only fields and properties of the declared type.
Expand Down Expand Up @@ -44,7 +44,7 @@ public EnumValuesAttribute(params string[] names)

public IEnumerable GetData(IParameterInfo parameter) => GetMembers(parameter.ParameterType, parameter.ParameterInfo?.Name);

internal IEnumerable<object> GetMembers(Type parameterType, string parameterName)
public IEnumerable<object> GetMembers(Type parameterType, string parameterName)
{
object[] data = GetMembersImpl(parameterType).ToArray();
if (data is null || data.Length == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
/// <summary>
/// Attribute on test assemblies, classes, or methods that run only against live resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class MockRequest : Request
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Text;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class MockResponse : Response
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;
using Azure.Core.Pipeline;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
public class MockTransport : HttpPipelineTransport
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.IO;

namespace Azure.Core.Testing
namespace Azure.Core.TestFramework
{
internal class NonSeekableMemoryStream : MemoryStream
public class NonSeekableMemoryStream : MemoryStream
{
public NonSeekableMemoryStream()
{
Expand Down
Loading

0 comments on commit b9bd85c

Please sign in to comment.