//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined
{
public abstract class BaselinedTestWithMultipleScripts : BaselinedTest
{
///
/// Holds the number of files that are associated with this test
///
private int _fileCount;
///
/// Gets or Sets the amount of scripts to process
///
public int FileCount
{
get
{
return _fileCount;
}
set
{
if (value < 1)
throw new ArgumentOutOfRangeException("FileCount", value, "FileCount must be > 0");
_fileCount = value;
}
}
///
/// Constructor
///
public BaselinedTestWithMultipleScripts()
: base()
{
//set invalid value
_fileCount = 0;
}
///
/// Runs the test
///
public override void Run()
{
//little self-assigning sanity check there (if invalid value, it will throw)
FileCount = FileCount;
//process all files
for (int n = 0; n < FileCount; n++)
{
ProcessFile(GetTestscriptFilePath(this.CurrentTestName, n));
}
PostProcessFiles();
Verify();
}
///
/// Starts a test with the specified fileCount
///
/// Name of the test
/// Number of files
public void Start(string name, int fileCount)
{
FileCount = fileCount;
base.Start(name);
}
///
/// This method gives you an opportunity to handle one specific file
///
/// Path to the current file
public abstract void ProcessFile(string filePath);
///
/// This method gives you an opportunity to perform any actions after files are processed
///
public virtual void PostProcessFiles()
{
}
///
/// This method will be called when all files have been processed; add verification logic here
///
public abstract void Verify();
}
}