// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net)
// All rights reserved.
//
// This file is part of Regionerate.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
using System.IO;
using NUnit.Framework;
using Rauchy.Regionerate.ServiceLayer.Components.Projects;
namespace Rauchy.Regionerate.ServiceLayer.Components.Tests
{
///
/// Tests the class.
///
[ TestFixture ]
public class SolutionTests
{
#region Data Members (1)
private const string ResourcesDirectory = @"Resources";
#endregion Data Members
#region Tests (4)
// [rgn] Public Methods (4)
[ Test ]
public void DoesNotLoadVisualBasicProject()
{
AssertThatNoProjectsLoad( "VisualBasicSoluion.sln" );
}
[ Test ]
public void LoadsBlankSolution()
{
AssertThatNoProjectsLoad( "BlankSolution.sln" );
}
[ Test ]
public void LoadsOnlyCSharpProjectsOnMixedSolution()
{
AssertThatSingleProjectLoads( "MixedSolution.sln", "Empty2005Project.csproj" );
}
[ Test ]
public void LoadsSingleCSharpProject()
{
AssertThatSingleProjectLoads( "SingleCSharpProject.sln", "Empty2005Project.csproj" );
}
#endregion Tests
#region Helper Methods (3)
// [rgn] Private Methods (3)
private static void AssertThatNoProjectsLoad( string solutionName )
{
string resourcePath = GetResourcePath( solutionName );
Solution solution = new Solution( resourcePath );
Assert.IsNull( solution.GetEnumerator().Current );
Assert.IsFalse( solution.GetEnumerator().MoveNext() );
}
private static void AssertThatSingleProjectLoads( string solutionName, string expectedProjectName )
{
string resourcePath = GetResourcePath( solutionName );
Solution solution = new Solution( resourcePath );
int itemCount = 0;
foreach ( Project project in solution )
{
Assert.AreEqual( expectedProjectName, project.Name );
itemCount++;
}
Assert.AreEqual( 1, itemCount );
}
///
/// Gets the path to a resource.
///
/// Name of the file.
private static string GetResourcePath( string fileName )
{
return Path.Combine( ResourcesDirectory, fileName );
}
#endregion Helper Methods
}
}