Class Diagnostic
Helper class for performing scaffolding operations.
Use Diagnose(DiagnoseMethod) to perform scaffolding operations.
Namespace: SuperOffice.Diagnostics
Assembly: SoCore.dll
Syntax
public class Diagnostic : Object
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
Methods
Assert(Boolean, String)
Report error message if the provided condition is not true.
Declaration
public void Assert(bool condition, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
Boolean | condition | condition to verify. |
String | errorMessage | Error message if the condition is false. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertEmpty<T>(T, String)
Report error message if the value is not empty. This means null for object types and '0' for value types.
Declaration
public void AssertEmpty<T>(T value, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to check if it is empty. |
String | errorMessage | Error message to pass on if the value is empty. |
Type Parameters
Name | Description |
---|---|
T | The type of value to check. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertEqual(Object, Object, String)
report error message if the actual value is different from the expected value.
Declaration
public void AssertEqual(object expected, object actual, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
Object | expected | The value expected. |
Object | actual | The actual value recieved. |
String | errorMessage | Error message to pass on if the values are not equal. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertEqual<T>(T, T, String)
Report error message if the actual value is not equal to the expected value using the
Declaration
public void AssertEqual<T>(T expected, T actual, string errorMessage)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | expected | The expected value |
T | actual | The actual value. |
String | errorMessage | Error message reported if the values are not equal. |
Type Parameters
Name | Description |
---|---|
T | Type of object to compare. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNotEmpty<T>(T, String)
Report error message if the value is empty. This means null for object types and '0' for value types.
Declaration
public void AssertNotEmpty<T>(T value, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to check if it is not empty. |
String | errorMessage | Error message to pass on if the value is not empty. |
Type Parameters
Name | Description |
---|---|
T | The type of value to check. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNotEqual(Object, Object, String)
Report error message if the actual value is equal to the expected value using the
Declaration
public void AssertNotEqual(object expected, object actual, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
Object | expected | The expected value |
Object | actual | The actual value. |
String | errorMessage | Error message reported if the values are equal. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNotEqual<T>(T, T, String)
Report error message if the actual value is equal to the expected value using the
Declaration
public void AssertNotEqual<T>(T expected, T actual, string errorMessage)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | expected | The expected value |
T | actual | The actual value. |
String | errorMessage | Error message reported if the values are equal. |
Type Parameters
Name | Description |
---|---|
T | Type of object to compare. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNotNull(Object, String)
Report error message if the value is null.
Declaration
public void AssertNotNull(object value, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
Object | value | Value to check if is null. |
String | errorMessage | Error message to pass on if the value is null |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNotSame<T>(T, T, String)
Report error message if the actual value is the same as the expected value using the IComparable interface.
Declaration
public void AssertNotSame<T>(T expected, T actual, string errorMessage)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | expected | The expected value |
T | actual | The actual value. |
String | errorMessage | Error message reported if the values are equal. |
Type Parameters
Name | Description |
---|---|
T | Type of object to compare. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertNull(Object, String)
Report error message if the value is not null.
Declaration
public void AssertNull(object value, string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
Object | value | Value to check if is null. |
String | errorMessage | Error message to pass on if the value is not null |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
AssertSame<T>(T, T, String)
Report errormessage if the actual value is not the same as the expected value using the IComparable interface.
Declaration
public void AssertSame<T>(T expected, T actual, string errorMessage)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | expected | The expected value |
T | actual | The actual value. |
String | errorMessage | Error message reported if the values are not equal. |
Type Parameters
Name | Description |
---|---|
T | Type of object to compare. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
Diagnose(DiagnoseMethod)
Carry out the diagnostic method in debug code and in "EnableScaffolding" is turned on in the configuration file.
Declaration
public static void Diagnose(DiagnoseMethod diagnoseMethod)
Parameters
Type | Name | Description |
---|---|---|
DiagnoseMethod | diagnoseMethod | Method to execute. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
Exceptions
Type | Condition |
---|---|
DiagnoseException | Thrown if errors occurs in hte executed code. |
Error(String)
Throw an exception with the message.
Declaration
public void Error(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | Error message to report |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
Information(String)
Report some information.
Declaration
public void Information(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
ToString()
Obtain information about the scaffolding results.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | String containing the scaffolding results. |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});
Warning(String)
Report a warning
Declaration
public void Warning(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | warning message |
Examples
The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.
Diagnostic.Diagnose(delegate(Diagnostic s)
{
string tmp = "hello";
if (tmp != "world")
s.Error("The strings are not equal");
});