Skip to content

Commit

Permalink
Removed duplicate tests from SubSonic.Tests that are now in SubSonic.…
Browse files Browse the repository at this point in the history
…Tests.Unit

Enabled build runner to execute SubSonic.Tests.Unit
  • Loading branch information
adam7 authored and adam7 committed Mar 5, 2010
1 parent 6a5736d commit 5d74822
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 2,156 deletions.
2 changes: 1 addition & 1 deletion SubSonic.Linq.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<UsingTask AssemblyFile="lib\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
<Target Name="Build">
<MSBuild Projects="SubSonic.Linq.sln" Targets="Build" Properties="Configuration=Debug" />
<!--<xunit assembly="SubSonic.Tests\bin\Debug\SubSonic.Tests.dll" />-->
<xunit assembly="SubSonic.TestsUnit\bin\Debug\SubSonic.Tests.Unit.dll" />
</Target>
</Project>
19 changes: 9 additions & 10 deletions SubSonic.Tests.Unit/LINQ/TestBases/LinqTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ public abstract class LinqTestsBase
{
protected TestDB _db;

protected static Regex whitespaceRegex = new Regex("\\s+");
protected static Regex carriageReturnRegex = new Regex("\r");

/// <summary>
/// Asserts the equality of expected and actual strings ignoring extra whitespace and carriage return.
/// </summary>
/// <param name="expected">The expected.</param>
/// <param name="actual">The actual.</param>
public void AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(string expected, string actual)
{
// Strip extra whitespace
expected = Regex.Replace(expected, "\\s+", " ");
actual = Regex.Replace(actual, "\\s+", " ");

// Strip carriage returns
expected = Regex.Replace(expected, "\r", "");
actual = Regex.Replace(actual, "\r", "");
// Strip extra whitespace and carriage returns
expected = ReplaceExtraWhitespaceAndCarriageReturn(expected);
actual = ReplaceExtraWhitespaceAndCarriageReturn(actual);

Assert.Equal(expected, actual);
}

string ReplaceExtraWhitespaceAndCarriageReturn(string input)
{
input = Regex.Replace(input, "\\s+", " ");
return Regex.Replace(input, "\r", "");
}
}
}
56 changes: 28 additions & 28 deletions SubSonic.Tests.Unit/LINQ/TestBases/SelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,41 @@ namespace SubSonic.Tests.Unit.Linq.TestBases
// [TestFixture]
public abstract class SelectTests : LinqTestsBase
{
#region Fields (1) 

protected ISelectTestsSql _selectTestsSql;

#endregion Fields 

#region Methods (58) 

// Public Methods (58) 

//[Fact]
//public void All_With_StartsWith()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result =
// _db.Customers.All(c => c.ContactName.StartsWith("x"));

// Assert.False(result);
//}
//[Fact]
//public void All_With_SubQuery()
//{
////TODO: Dates are culture specific
// var result =
// _db.Customers.Where(
// c => _db.Orders.Where(o => o.CustomerID == c.CustomerID).All(o => o.OrderDate > DateTime.Parse("5/1/2008")));

[Fact]
public void All_With_SubQuery()
{
var result =
_db.Customers.Where(
c => _db.Orders.Where(o => o.CustomerID == c.CustomerID).All(o => o.OrderDate > DateTime.Parse("5/1/2008")));

AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(_selectTestsSql.All_With_SubQuery, result.GetQueryText());
}

// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(_selectTestsSql.All_With_SubQuery, result.GetQueryText());
//}
//[Fact]
//public void Any_Should_Not_Fail()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// Assert.True(_db.Products.Any(x => x.ProductID == 1));
//}

[Fact]
public void Any_With_Collection()
{
Expand Down Expand Up @@ -106,12 +112,11 @@ public void Count_Distinct()
//[Fact]
//public void Count_Distinct_With_Arg()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result = _db.Customers.Distinct().Count(x => x.CustomerID == "TEST1");

// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(1, result);
//}

[Fact]
public void Count_No_Args()
{
Expand All @@ -123,11 +128,10 @@ public void Count_No_Args()
//[Fact]
//public void Count_With_SingleArg()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result = _db.Orders.Count(x => x.OrderID > 0);
// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(100, result);
//}

[Fact]
public void Distinct_GroupBy()
{
Expand Down Expand Up @@ -162,10 +166,9 @@ public void Distinct_Should_Return_69_For_Scalar_CustomerCity_Ordered()
//[Fact]
//public void First_Product_Should_Have_ProductID_1()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// Assert.True(_db.Products.First().ProductID == 1);
//}

[Fact]
public void GroupBy_Basic()
{
Expand All @@ -179,7 +182,6 @@ public void GroupBy_Distinct()
var result = _db.Orders.GroupBy(o => o.CustomerID).Distinct();
AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(_selectTestsSql.GroupBy_Distinct, result.GetQueryText());
}


[Fact]
public void GroupBy_SelectMany()
Expand Down Expand Up @@ -550,15 +552,14 @@ public void Select_Scalar()
//[Fact]
//public void Select_Single_Product_With_ID_1()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result = (from p in _db.Products
// where p.ProductID == 1
// select p).SingleOrDefault();

// Assert.NotNull(result);
// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(1, result.ProductID);
//}

[Fact]
public void SelectMany_Customer_Orders()
{
Expand All @@ -577,26 +578,23 @@ from o in _db.Orders
//[Fact]
//public void Single_Product_Should_Have_ProductID_1()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// Assert.True(_db.Products.Single(x => x.ProductID == 1).ProductID == 1);
//}

//[Fact]
//public void Sum_No_Args()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result = _db.Orders.Select(o => o.OrderID).Sum();
// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(5050, result);
//}

//[Fact]
//public void Sum_With_SingleArg()
//{
// // Hits DB
// // TODO: Hits DB, need to fix this
// var result = _db.Orders.Sum(x => x.OrderID);
// AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(5050, result);
//}

[Fact]
public void Where_Resolves_String_EndsWith_Literal()
{
Expand Down Expand Up @@ -650,6 +648,8 @@ public void Where_Resolves_String_StartsWith_OtherColumn()

AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(_selectTestsSql.Where_Resolves_String_StartsWith_OtherColumn, result.GetQueryText());
}

#endregion Methods 
}
// ReSharper restore InconsistentNaming
}
10 changes: 10 additions & 0 deletions SubSonic.Tests.Unit/LINQ/TestBases/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ namespace SubSonic.Tests.Unit.Linq.TestBases
// ReSharper disable InconsistentNaming
public abstract class StringTests : LinqTestsBase
{
#region Fields (1) 

protected IStringTestsSql _stringTestsSql;

#endregion Fields 

#region Methods (22) 

// Public Methods (22) 

[Fact]
public void String_CompareEQ()
{
Expand Down Expand Up @@ -185,6 +193,8 @@ public void String_Trim()

AssertEqualIgnoringExtraWhitespaceAndCarriageReturn(_stringTestsSql.String_Trim, result.GetQueryText());
}

#endregion Methods 
}

// ReSharper restore InconsistentNaming
Expand Down
48 changes: 0 additions & 48 deletions SubSonic.Tests/DataProviders/ProviderFactoryTests.cs

This file was deleted.

Loading

0 comments on commit 5d74822

Please sign in to comment.