Move Integration Tests to dedicated project (#201)

Add IntegrationTests project. Move all tests ifdef'd with LIVE_CONNECTION_TESTS to IntegrationTests project. Delete files that have no remaining code. Update codecoverage.bat to run integration tests
This commit is contained in:
Connor Quagliana
2017-01-04 11:37:57 -08:00
committed by GitHub
parent 5b41538d22
commit 3ad7cc1a8b
16 changed files with 647 additions and 435 deletions

View File

@@ -1,110 +0,0 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#if LIVE_CONNECTION_TESTS
using System;
using System.Data.Common;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Microsoft.SqlTools.Test.Utility;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution.DataStorage
{
public class StorageDataReaderTests
{
private StorageDataReader GetTestStorageDataReader(out DbDataReader reader, string query)
{
ScriptFile scriptFile;
ConnectionInfo connInfo = TestObjects.InitLiveConnectionInfo(out scriptFile);
var command = connInfo.SqlConnection.CreateCommand();
command.CommandText = query;
reader = command.ExecuteReader();
return new StorageDataReader(reader);
}
/// <summary>
/// Validate GetBytesWithMaxCapacity
/// </summary>
[Fact]
public void GetBytesWithMaxCapacityTest()
{
DbDataReader reader;
var storageReader = GetTestStorageDataReader(
out reader,
"SELECT CAST([name] as TEXT) As TextName FROM sys.all_columns");
reader.Read();
Assert.False(storageReader.IsDBNull(0));
byte[] bytes = storageReader.GetBytesWithMaxCapacity(0, 100);
Assert.NotNull(bytes);
}
/// <summary>
/// Validate GetCharsWithMaxCapacity
/// </summary>
[Fact]
public void GetCharsWithMaxCapacityTest()
{
DbDataReader reader;
var storageReader = GetTestStorageDataReader(
out reader,
"SELECT name FROM sys.all_columns");
reader.Read();
Assert.False(storageReader.IsDBNull(0));
Assert.NotNull(storageReader.GetValue(0));
string shortName = storageReader.GetCharsWithMaxCapacity(0, 2);
Assert.True(shortName.Length == 2);
Assert.Throws<ArgumentOutOfRangeException>(() => storageReader.GetBytesWithMaxCapacity(0, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => storageReader.GetCharsWithMaxCapacity(0, 0));
}
/// <summary>
/// Validate GetXmlWithMaxCapacity
/// </summary>
[Fact]
public void GetXmlWithMaxCapacityTest()
{
DbDataReader reader;
var storageReader = GetTestStorageDataReader(
out reader,
"SELECT CAST('<xml>Test XML context</xml>' AS XML) As XmlColumn");
reader.Read();
Assert.False(storageReader.IsDBNull(0));
string shortXml = storageReader.GetXmlWithMaxCapacity(0, 2);
Assert.True(shortXml.Length == 3);
}
/// <summary>
/// Validate StringWriterWithMaxCapacity Write test
/// </summary>
[Fact]
public void StringWriterWithMaxCapacityTest()
{
var writer = new StorageDataReader.StringWriterWithMaxCapacity(null, 4);
string output = "...";
writer.Write(output);
Assert.True(writer.ToString().Equals(output));
writer.Write('.');
Assert.True(writer.ToString().Equals(output + '.'));
writer.Write(output);
writer.Write('.');
Assert.True(writer.ToString().Equals(output + '.'));
}
}
}
#endif