Update of /cvsroot/ccnetcontrib/ccnetcontrib/src/VSSPlugin.Test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32474/src/VSSPlugin.Test
Added Files:
App.config FunctionalTest.cs CommonAssemblyInfo.cs
AssemblyInfo.cs DirectoryDeleter.cs .cvsignore
VSSSourceControlTest.cs VSSPlugin.Test.csproj
Log Message:
Moving VSSPlugin into common src tree, and adding vssplugin specific targets to build script.
--- NEW FILE: .cvsignore ---
VSSPlugin.Test.csproj.user
bin
obj
--- NEW FILE: DirectoryDeleter.cs ---
using System.IO;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin.Test
{
public class DirectoryDeleter
{
public static void Delete(string workingDirectory)
{
if (Directory.Exists(workingDirectory))
{
FileSystemInfo[] fsInfos = new DirectoryInfo(workingDirectory).GetFileSystemInfos();
foreach (FileSystemInfo fsInfo in fsInfos)
{
fsInfo.Attributes = FileAttributes.Normal;
}
Directory.Delete(workingDirectory, true);
}
}
}
}
--- NEW FILE: CommonAssemblyInfo.cs ---
using System.Reflection;
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
[assembly: AssemblyVersionAttribute("0")]
[assembly: AssemblyCopyrightAttribute("Copyright © 2004 ThoughtWorks Inc.")]
[assembly: AssemblyCompanyAttribute("ThoughtWorks")]
[assembly: AssemblyProductAttribute("CruiseControl.NET")]
--- NEW FILE: VSSSourceControlTest.cs ---
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using Exortech.NetReflector;
using NUnit.Framework;
using ThoughtWorks.CruiseControl.Core;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin.Test
{
[TestFixture, Category("Functional TestFixture")]
public class VSSSourceControlTest
{
private VSSSourceControl vss;
[SetUp]
public void LoadValuesFromConfigFile()
{
vss = new VSSSourceControl();
vss.SrcSafeIni = ConfigurationSettings.AppSettings["SrcSafeIni"];
vss.Username = ConfigurationSettings.AppSettings["Username"];
vss.Password = ConfigurationSettings.AppSettings["Password"];
vss.Project = ConfigurationSettings.AppSettings["Project"];
}
[Test]
public void PopulateFromXml()
{
string xml = @"<vssplugin autoGetSource=""false"">
<srcSafeIni>D:\Program Files\Microsoft Visual Studio\VSS\srcsafe.ini</srcSafeIni>
<username>bob</username>
<password>brown</password>
<project>$/Root</project>
<labelComment>Foo</labelComment>
</vssplugin>";
VSSSourceControl vss = (VSSSourceControl) NetReflector.Read(xml);
Assert.AreEqual(@"D:\Program Files\Microsoft Visual Studio\VSS\srcsafe.ini", vss.SrcSafeIni);
Assert.AreEqual("bob", vss.Username);
Assert.AreEqual("brown", vss.Password);
Assert.AreEqual("$/Root", vss.Project);
Assert.AreEqual("Foo", vss.LabelComment);
Assert.IsFalse(vss.AutoGetSource);
}
[Test]
public void GetAllModifications()
{
DateTime from = DateTime.MinValue;
DateTime to = DateTime.MaxValue;
Modification[] modifications = vss.GetModifications(from, to);
Assert.IsTrue(modifications.Length > 0, "No modifications returned.");
Assert.IsTrue(modifications[0].ModifiedTime > from);
Assert.IsTrue(modifications[0].ModifiedTime < to);
Assert.IsNotNull(modifications[0].UserName);
Assert.IsNotNull(modifications[0].Type);
Assert.IsNotNull(modifications[0].FolderName);
Assert.IsNotNull(modifications[0].FileName);
}
[Test, ExpectedException(typeof(CruiseControlException))]
public void ShouldThrowCruiseControlExceptionIfSrcSafeIniLocationIsInvalid()
{
vss.SrcSafeIni = @"D:\Program Files\Microsoft Visual Studio\";
vss.GetModifications(DateTime.Today, DateTime.Now);
}
[Test, ExpectedException(typeof(CruiseControlException))]
public void ShouldThrowCruiseControlExceptionIfProjectRootIsInvalid()
{
vss.Project = "does-not-exist";
vss.GetModifications(DateTime.Today, DateTime.Now);
}
[Test, ExpectedException(typeof(CruiseControlException))]
public void ShouldThrowCruiseControlExceptionIfItemIsNotAProject()
{
vss.Project = "$/Refactoring/Rental.cs";
vss.GetModifications(DateTime.Today, DateTime.Now);
}
[Test]
public void RunShouldSetModificationsOnIntegrationResult()
{
IntegrationResult result = new IntegrationResult();
result.StartTime = DateTime.MinValue;
vss.Run(result);
Assert.IsTrue(result.Modifications.Length > 0, "No modifications returned.");
}
[Test]
public void ShouldLabelAllItemsUnderRootProject()
{
vss.LabelSourceControl("hello", DateTime.Now.AddDays(-2));
Modification[] mods = vss.GetModifications("hello");
Assert.IsTrue(mods.Length > 0, "No modifications returned.");
}
[Test]
public void ShouldGetVersionOfSourceAtSpecifiedDate()
{
string tempPath = Path.Combine(Path.GetTempPath(), "VssPlugin");
DirectoryDeleter.Delete(tempPath);
IntegrationResult result = new IntegrationResult();
result.WorkingDirectory = tempPath;
vss.GetSource(result);
Assert.IsTrue(Directory.Exists(result.WorkingDirectory));
Assert.IsTrue(Directory.GetFiles(result.WorkingDirectory).Length > 0, "Directory does not contain any files.");
}
[Test]
public void ShouldNotGetSourceIfAutoGetSourceIsFalse()
{
string tempPath = Path.Combine(Path.GetTempPath(), "VssPlugin");
DirectoryDeleter.Delete(tempPath);
IntegrationResult result = new IntegrationResult();
result.WorkingDirectory = tempPath;
vss.AutoGetSource = false;
vss.GetSource(result);
Assert.IsFalse(Directory.Exists(tempPath));
}
private void WriteOutModifications(Modification[] modifications)
{
foreach (Modification mod in modifications)
{
Debug.WriteLine(mod.ToString());
}
}
}
}
--- NEW FILE: FunctionalTest.cs ---
using System;
using System.Configuration;
using System.IO;
using System.Threading;
using NUnit.Framework;
using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Remote;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin.Test
{
[TestFixture]
public class FunctionalTest
{
[Test]
public void RunSingleIntegration()
{
string workingDirectory = CreateWorkingDirectory();
string configFile = CreateConfigFile(workingDirectory);
ICruiseServer server = CruiseServerFactory.CreateLocal(configFile);
server.ForceBuild("vss");
Thread.Sleep(100);
server.Stop();
Assert.IsTrue(Directory.Exists(workingDirectory));
}
private string CreateWorkingDirectory()
{
string workingDirectory = Path.Combine(Path.GetTempPath(), "vssplugin");
DirectoryDeleter.Delete(workingDirectory);
return workingDirectory;
}
private string CreateConfigFile(string workingDirectory)
{
string configFile = Path.GetTempFileName();
using (StreamWriter writer = File.CreateText(configFile))
{
writer.Write(GetVssPluginXml(workingDirectory));
}
return configFile;
}
private string GetVssPluginXml(string workingDirectory)
{
string project = ConfigurationSettings.AppSettings["Project"];
return string.Format(@"<cruisecontrol>
<project name=""vss"" workingDirectory=""{0}"">
<build type=""mockbuildrunner"" />
<sourcecontrol type=""vssplugin"" >
<project>{1}</project>
</sourcecontrol>
</project>
</cruisecontrol>", workingDirectory, project);
}
}
}
--- NEW FILE: VSSPlugin.Test.csproj ---
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{DFC1B086-DB8F-45F5-A734-E2C43DA409C0}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "ThoughtWorks.CruiseControl.Contrib.VSSPlugin.Test"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = 'copy "$(ProjectDir)App.config" "$(TargetPath).config"'
RootNamespace = "ThoughtWorks.CruiseControl.Contrib.VSSPlugin.Test"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Build"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = ""
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "..\..\build\VSSPlugin.Test\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "1"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "VSSPlugin"
Project = "{F1F13F30-E452-42B4-9BCE-0A228FEE8C65}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
Name = "SourceSafeTypeLib"
Guid = "{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}"
VersionMajor = "5"
VersionMinor = "1"
Lcid = "0"
WrapperTool = "tlbimp"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "ThoughtWorks.CruiseControl.Remote"
AssemblyName = "ThoughtWorks.CruiseControl.Remote"
HintPath = "..\..\lib\ThoughtWorks.CruiseControl.Remote.dll"
/>
<Reference
Name = "NetReflector"
AssemblyName = "NetReflector"
HintPath = "..\..\lib\NetReflector.dll"
/>
<Reference
Name = "nmock"
AssemblyName = "nmock"
HintPath = "..\..\lib\nmock.dll"
/>
<Reference
Name = "nunit.core"
AssemblyName = "nunit.core"
HintPath = "..\..\lib\nunit.core.dll"
/>
<Reference
Name = "nunit.framework"
AssemblyName = "nunit.framework"
HintPath = "..\..\lib\nunit.framework.dll"
/>
<Reference
Name = "ThoughtWorks.CruiseControl.Core"
AssemblyName = "ThoughtWorks.CruiseControl.Core"
HintPath = "..\..\lib\ThoughtWorks.CruiseControl.Core.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "App.config"
BuildAction = "None"
/>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CommonAssemblyInfo.cs"
BuildAction = "Compile"
/>
<File
RelPath = "DirectoryDeleter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "FunctionalTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "VSSSourceControlTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
--- NEW FILE: App.config ---
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- <add key="SrcSafeIni" value="C:\Program Files\Microsoft Visual Studio\VSS\srcsafe.ini" /> Not required -->
<add key="Username" value="Guest" />
<add key="Password" value="" />
<add key="Project" value="$/Refactoring" />
</appSettings>
</configuration>
--- NEW FILE: AssemblyInfo.cs ---
using System.Reflection;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly : AssemblyTitle("CC.NET Contrib VSS Plugin Tests")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
|