Skip to content

Commit ebd2864

Browse files
committed
project clean up
removed non used files/types moved types around project/namespaces to declutter the intellisense experience
1 parent ca40a1b commit ebd2864

19 files changed

+112
-176
lines changed

TestStack.ConventionTests.Tests/ProjectBasedConventions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using NSubstitute;
66
using NUnit.Framework;
77
using TestStack.ConventionTests.Conventions;
8-
using TestStack.ConventionTests.Helpers;
8+
using TestStack.ConventionTests.Internal;
99
using TestStack.ConventionTests.Tests.Properties;
1010

1111
[TestFixture]
Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
namespace TestStack.ConventionTests
22
{
33
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Reflection;
7-
using System.Text;
84
using ApprovalTests;
95

106
public static class Convention
@@ -34,61 +30,16 @@ public static void Is<TData>(IConvention<TData> convention, TData data) where TD
3430
Settings.AssertZero(result.InvalidResultsCount, result.Message);
3531
}
3632

37-
38-
public static void Is<T>(ConventionData<T> convention, IEnumerable<T> itemsToVerify)
39-
{
40-
var results = Result(convention, itemsToVerify);
41-
if (!string.IsNullOrEmpty(results))
42-
throw new ConventionFailedException(results);
43-
}
44-
45-
public static void Is<TConvention, T>(TConvention convention, IEnumerable<T> itemsToVerify, Func<string, bool> itemFilter)
46-
where TConvention : ConventionData<T>, IRuntimeFilter<string>
47-
{
48-
Is<TConvention, T, string>(convention, itemsToVerify, itemFilter);
49-
}
50-
51-
public static void Is<TConvention, T, TItem>(TConvention convention, IEnumerable<T> itemsToVerify, Func<TItem, bool> itemFilter)
52-
where TConvention : ConventionData<T>, IRuntimeFilter<TItem>
33+
public class ConventionSettings
5334
{
54-
var results = Result(convention, itemsToVerify, itemFilter);
55-
if (!string.IsNullOrEmpty(results))
56-
throw new ConventionFailedException(results);
57-
}
35+
public Action<String> AssertInclunclusive;
5836

59-
public static string Result<T>(ConventionData<T> convention, IEnumerable<T> itemsToVerify)
60-
{
61-
var message = new StringBuilder();
62-
var invalidItems = itemsToVerify.Where(i => !convention.Must(i)).ToArray();
63-
if (!invalidItems.Any()) return null;
37+
public Action<int, string> AssertZero;
6438

65-
message.AppendLine(convention.Description ?? "Convention has failing items");
66-
foreach (var invalidType in invalidItems)
39+
public ConventionSettings()
6740
{
68-
message.Append('\t');
69-
convention.ItemDescription(invalidType, message);
41+
// TODO: initialize the type;
7042
}
71-
72-
return message.ToString();
7343
}
74-
75-
public static string Result<TConvention, T, TItem>(TConvention convention, IEnumerable<T> itemsToVerify, Func<TItem, bool> itemFilter)
76-
where TConvention : ConventionData<T>, IRuntimeFilter<TItem>
77-
{
78-
convention.SetFilter(itemFilter);
79-
return Result(convention, itemsToVerify);
80-
}
81-
}
82-
83-
public class ConventionSettings
84-
{
85-
public ConventionSettings()
86-
{
87-
// TODO: initialize the type;
88-
}
89-
90-
public Action<String> AssertInclunclusive;
91-
92-
public Action<int, string> AssertZero;
9344
}
9445
}

TestStack.ConventionTests/ConventionData`1.cs renamed to TestStack.ConventionTests/ConventionData.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@
88
/// </summary>
99
public class ConventionData<TItem>
1010
{
11-
readonly Action<TItem, StringBuilder> defaultItemDescription = DefaultItemDescriptionMethod;
1211
public static readonly Predicate<TItem> None = _ => false;
13-
14-
static void DefaultItemDescriptionMethod(TItem item, StringBuilder message)
15-
{
16-
message.AppendLine(ReferenceEquals(item, null) ? "<<null>>" : item.ToString());
17-
}
12+
readonly Action<TItem, StringBuilder> defaultItemDescription = DefaultItemDescriptionMethod;
1813

1914
public ConventionData()
2015
{
@@ -26,17 +21,24 @@ public ConventionData()
2621
public Func<TItem, object> OrderBy { get; set; }
2722

2823
/// <summary>
29-
/// Descriptive text used for failure message in test. Should explan what is wrong, and how to fix it (how to make types that do not conform to the convention do so).
24+
/// Descriptive text used for failure message in test. Should explan what is wrong, and how to fix it (how to make
25+
/// types that do not conform to the convention do so).
3026
/// </summary>
3127
public string Description { get; set; }
3228

3329
/// <summary>
34-
/// This is the convention. The predicate should return <c>true</c> for types that do conform to the convention, and <c>false</c> otherwise
30+
/// This is the convention. The predicate should return <c>true</c> for types that do conform to the convention, and
31+
/// <c>false</c> otherwise
3532
/// </summary>
3633
public Predicate<TItem> Must { get; set; }
3734

3835
public Action<TItem, StringBuilder> ItemDescription { get; set; }
3936

37+
static void DefaultItemDescriptionMethod(TItem item, StringBuilder message)
38+
{
39+
message.AppendLine(ReferenceEquals(item, null) ? "<<null>>" : item.ToString());
40+
}
41+
4042
object HashCode(TItem arg)
4143
{
4244
if (ReferenceEquals(arg, null))

TestStack.ConventionTests/ConventionFailedException.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

TestStack.ConventionTests/Conventions/AllClassesHaveDefaultConstructor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace TestStack.ConventionTests.Conventions
22
{
33
using System.Linq;
4-
using TestStack.ConventionTests.Helpers;
54
using TestStack.ConventionTests.Internal;
65

76
public class AllClassesHaveDefaultConstructor : IConvention<Types>

TestStack.ConventionTests/Conventions/AllMethodsAreVirtual.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Text;
8-
using TestStack.ConventionTests.Helpers;
98
using TestStack.ConventionTests.Internal;
109

1110
public class AllMethodsAreVirtual : IConvention<Types>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace TestStack.ConventionTests.Conventions
2+
{
3+
using System;
4+
using System.Reflection;
5+
using System.Xml.Linq;
6+
using TestStack.ConventionTests.Internal;
7+
8+
public class Project : IConventionData
9+
{
10+
public Func<string, bool> Includes;
11+
12+
public Project(Assembly assembly, IProjectProvider projectProvider, IProjectLocator projectLocator)
13+
{
14+
Assembly = assembly;
15+
ProjectProvider = projectProvider;
16+
ProjectLocator = projectLocator;
17+
}
18+
19+
public Assembly Assembly { get; private set; }
20+
21+
public IProjectLocator ProjectLocator { get; private set; }
22+
23+
public IProjectProvider ProjectProvider { get; private set; }
24+
25+
public bool HasValidSource
26+
{
27+
get { return ProjectLocator.ResolveProjectFilePath(Assembly) != null; }
28+
}
29+
30+
public bool HasApprovedExceptions { get; set; }
31+
32+
public XDocument GetProject()
33+
{
34+
var location = ProjectLocator.ResolveProjectFilePath(Assembly);
35+
var project = ProjectProvider.LoadProjectDocument(location);
36+
return project;
37+
}
38+
}
39+
}

TestStack.ConventionTests/Types.cs renamed to TestStack.ConventionTests/Conventions/Types.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TestStack.ConventionTests
1+
namespace TestStack.ConventionTests.Conventions
22
{
33
using System;
44
using System.Linq;

TestStack.ConventionTests/IConvention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
using TestStack.ConventionTests.Internal;
44

5-
public interface IConvention<T> where T : IConventionData
5+
public interface IConvention<in T> where T : IConventionData
66
{
77
ConventionResult Execute(T data);
88
}

TestStack.ConventionTests/IRuntimeFilter.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)