Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.PerfTests/CreateTestDbAttribute.cs
Leila Lali b353b2137e New test common project for database connections using the settings.json (#210)
* moved test driver tests and test common classes to separate projects
2017-01-11 13:47:56 -08:00

40 lines
1.2 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit.Sdk;
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
{
/// <summary>
/// The attribute for each test to create the test db before the test starts
/// </summary>
public class CreateTestDbAttribute : BeforeAfterTestAttribute
{
public CreateTestDbAttribute(TestServerType serverType)
{
ServerType = serverType;
}
public CreateTestDbAttribute(int serverType)
{
ServerType = (TestServerType)serverType;
}
public TestServerType ServerType { get; set; }
public override void Before(MethodInfo methodUnderTest)
{
Task task = SqlTestDb.CreateNew(ServerType, doNotCleanupDb: true, databaseName: Common.PerfTestDatabaseName, query: Scripts.CreateDatabaseObjectsQuery);
task.Wait();
}
public override void After(MethodInfo methodUnderTest)
{
}
}
}