Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jediwhale
committed
Feb 23, 2009
1 parent
65f9e69
commit 7d9c436
Showing
12 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ bin/ | |
obj/ | ||
TestResult.xml | ||
*.cache | ||
*.bat | ||
fitnesse*.cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright © Syterra Software Inc. All rights reserved. | ||
// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | ||
// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing | ||
// to be bound by the terms of this license. You must not remove this notice, or any other, from this software. | ||
|
||
using System; | ||
using fitnesse.mtee.engine; | ||
using fitnesse.mtee.exception; | ||
using fitnesse.mtee.model; | ||
|
||
namespace fitnesse.slim.operators { | ||
public class ComposeException: ComposeOperator<string> { | ||
private const string ExceptionResult = "__EXCEPTION__:{0}"; | ||
|
||
public bool TryCompose(Processor<string> processor, TypedValue instance, ref Tree<string> result) { | ||
if (!typeof(Exception).IsAssignableFrom(instance.Type)) return false; | ||
|
||
if (TryResult<MemberException>(instance, | ||
e => string.Format("NO_METHOD_IN_CLASS {0} {1}", e.MemberName, e.Type), ref result)) return true; | ||
|
||
if (TryResult<ConstructorException>(instance, | ||
e => string.Format("NO_CONSTRUCTOR {0}", e.Type), ref result)) return true; | ||
|
||
result = MakeResult(instance.Value.ToString()); | ||
return true; | ||
} | ||
|
||
private delegate string Format<T>(T exception); | ||
|
||
private static bool TryResult<T>(TypedValue exception, Format<T> formatter, ref Tree<string> result) where T: class { | ||
var candidateException = exception.Value as T; | ||
if (candidateException == null) return false; | ||
result = MakeResult(string.Format("message<<{0}>> {1}", formatter(candidateException), candidateException)); | ||
return true; | ||
} | ||
|
||
private static Tree<string> MakeResult(string message) { | ||
return new TreeLeaf<string>(string.Format(ExceptionResult, message)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright © Syterra Software Inc. All rights reserved. | ||
// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | ||
// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing | ||
// to be bound by the terms of this license. You must not remove this notice, or any other, from this software. | ||
|
||
using System; | ||
|
||
namespace fitnesse.mtee.exception { | ||
public class ConstructorException: ApplicationException { | ||
public Type Type { get; private set; } | ||
public int ParameterCount { get; private set; } | ||
|
||
public ConstructorException(Type type, int parameterCount) | ||
: base(string.Format("Constructor with {1} parameter(s) not found for type '{0}'.", type.FullName, parameterCount)) { | ||
Type = type; | ||
ParameterCount = parameterCount; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters