Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Added ASP.NET template test
Browse files Browse the repository at this point in the history
* Extracted General and Other category in TestBase
* Create a method which geneates projectname from template name by cleaning it of any special chars
* Refactored MonoDevelopTemplatesTest to remove redundent information
  • Loading branch information
manish committed Apr 15, 2015
1 parent c073529 commit fbb911c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 11 deletions.
13 changes: 12 additions & 1 deletion main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs
Expand Up @@ -27,27 +27,38 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;

using MonoDevelop.Core;

using NUnit.Framework;

namespace UserInterfaceTests
{
public abstract class CreateBuildTemplatesTestBase: UITestBase
{
public string GeneralKindRoot { get; private set; } = "General";

public string OtherCategoryRoot { get; private set; } = "Other";

public readonly static Action EmptyAction = () => { };

public readonly static Action WaitForPackageUpdate = delegate {
Ide.WaitUntil (() => Ide.GetStatusMessage () == "Package updates are available.",
pollStep: 1000, timeout: 30000);
};

static Regex cleanSpecialChars = new Regex ("[^0-9a-zA-Z]+", RegexOptions.Compiled);

public CreateBuildTemplatesTestBase () {}

public CreateBuildTemplatesTestBase (string mdBinPath) : base (mdBinPath) {}

public string GenerateProjectName (string templateName)
{
return cleanSpecialChars.Replace (templateName, string.Empty);
}

public void AssertExeHasOutput (string exe, string expectedOutput)
{
var sw = new StringWriter ();
Expand Down
@@ -0,0 +1,83 @@
//
// ASPNetTemplatesTest.cs
//
// Author:
// Manish Sinha <manish.sinha@xamarin.com>
//
// Copyright (c) 2015 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using NUnit.Framework;

namespace UserInterfaceTests
{
public class ASPNetTemplatesTest : CreateBuildTemplatesTestBase
{
readonly string aspCategory = "ASP.NET";

[Test]
public void TestEmptyASPMVCProject ()
{
RunASPTest ("Empty ASP.NET MVC Project", WaitForPackageUpdate);
}

[Test]
public void TestEmptyASPProject ()
{
RunASPTest ("Empty ASP.NET Project", EmptyAction);
}

[Test]
public void TestASPMVCProject ()
{
RunASPTest ("ASP.NET MVC Project", WaitForPackageUpdate);
}

[Test]
public void TestASPMVCProjectWithUnitTests ()
{
RunASPTest ("ASP.NET MVC Project with Unit Tests", WaitForPackageUpdate);
}

[Test]
public void TestASPMVCMazorProject ()
{
RunASPTest ("ASP.NET MVC Razor Project", WaitForPackageUpdate);
}

[Test]
public void TestASPMVCMazorProjectWithUnitTests ()
{
RunASPTest ("ASP.NET MVC Razor Project with Unit Tests", WaitForPackageUpdate);
}

[Test]
public void TestASPProject ()
{
RunASPTest ("ASP.NET Project", EmptyAction);
}

void RunASPTest (string templateName, Action beforeBuild)
{
CreateBuildProject (GenerateProjectName (templateName), OtherCategoryRoot, aspCategory, GeneralKindRoot, templateName, beforeBuild);
}
}
}
Expand Up @@ -33,33 +33,35 @@ namespace UserInterfaceTests
{
public class MonoDevelopTemplatesTest : CreateBuildTemplatesTestBase
{
readonly static string DotNetProjectKind = ".NET";

readonly static string categoryRoot = "Other";
readonly static string generalKindRoot = "General";
readonly string dotNetCategory = ".NET";

[Test]
public void TestCreateBuildConsoleProject ()
{
CreateBuildProject ("ConsoleProject", categoryRoot, DotNetProjectKind, generalKindRoot ,"Console Project", EmptyAction);
RunDotNetTests ("Console Project", EmptyAction);
}

[Test]
public void TestCreateBuildGtkSharp20Project ()
{
CreateBuildProject ("Gtk20Project", categoryRoot, DotNetProjectKind, generalKindRoot, "Gtk# 2.0 Project", EmptyAction);
RunDotNetTests ("Gtk# 2.0 Project", EmptyAction);
}

[Test]
public void TestCreateBuildLibrary ()
{
CreateBuildProject ("Library", categoryRoot, DotNetProjectKind, generalKindRoot,"Library", EmptyAction);
RunDotNetTests ("Library", EmptyAction);
}

[Test]
public void TestCreateBuildNUnitLibraryProject ()
{
CreateBuildProject ("NUnitLibraryProject", categoryRoot, DotNetProjectKind, generalKindRoot, "NUnit Library Project", WaitForPackageUpdate);
RunDotNetTests ("NUnit Library Project", WaitForPackageUpdate);
}

void RunDotNetTests (string templateName, Action beforeBuild)
{
CreateBuildProject (GenerateProjectName (templateName), OtherCategoryRoot, dotNetCategory, GeneralKindRoot, templateName, beforeBuild);
}
}
}
2 changes: 1 addition & 1 deletion main/tests/UserInterfaceTests/NewProjectController.cs
Expand Up @@ -37,7 +37,7 @@ public class NewProjectController
get { return TestService.Session; }
}

public void Open (int delay = 2000)
public void Open ()
{
Session.ExecuteCommand (FileCommands.NewProject);
Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Projects.GtkNewProjectDialogBackend"));
Expand Down
6 changes: 5 additions & 1 deletion main/tests/UserInterfaceTests/UserInterfaceTests.csproj
Expand Up @@ -48,9 +48,10 @@
<Compile Include="ProcessUtils.cs" />
<Compile Include="Ide.cs" />
<Compile Include="CreateBuildTemplatesTestBase.cs" />
<Compile Include="MonoDevelopTemplatesTest.cs" />
<Compile Include="NewProjectController.cs" />
<Compile Include="UITestDebug.cs" />
<Compile Include="MonoDevelopTests\DotNetTemplatesTest.cs" />
<Compile Include="MonoDevelopTests\ASPNETTemplateTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand All @@ -65,4 +66,7 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="MonoDevelopTests\" />
</ItemGroup>
</Project>

0 comments on commit fbb911c

Please sign in to comment.