-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from PlayFab/master
Pushing new version
- Loading branch information
Showing
17 changed files
with
910 additions
and
1,008 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
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 |
---|---|---|
@@ -1,152 +1,109 @@ | ||
/* | ||
* UUnit system from UnityCommunity | ||
* Heavily modified | ||
* 0.4 release by pboechat | ||
* http://wiki.unity3d.com/index.php?title=UUnit | ||
* http://creativecommons.org/licenses/by-sa/3.0/ | ||
*/ | ||
|
||
using System; | ||
|
||
namespace PlayFab.UUnit | ||
{ | ||
public class UUnitAssert | ||
{ | ||
public static double DEFAULT_DOUBLE_PRECISION = 0.000001; | ||
|
||
private UUnitAssert() | ||
{ | ||
} | ||
|
||
public static void Skip() | ||
{ | ||
throw new UUnitSkipException(); | ||
} | ||
|
||
public static void Fail(string message = null) | ||
{ | ||
if (string.IsNullOrEmpty(message)) | ||
message = "fail"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void True(bool boolean, string message = null) | ||
{ | ||
if (boolean) | ||
{ | ||
return; | ||
} | ||
if (string.IsNullOrEmpty(message)) | ||
throw new UUnitAssertException(true, false); | ||
else | ||
throw new UUnitAssertException(true, false, message); | ||
} | ||
|
||
public static void False(bool boolean, string message = null) | ||
{ | ||
if (!boolean) | ||
{ | ||
return; | ||
} | ||
if (string.IsNullOrEmpty(message)) | ||
throw new UUnitAssertException(true, false); | ||
else | ||
throw new UUnitAssertException(true, false, message); | ||
} | ||
|
||
public static void NotNull(object something, string message = null) | ||
{ | ||
if (something != null) | ||
return; // Success | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Null object"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void Null(object something, string message = null) | ||
{ | ||
if (something == null) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Not null object"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void Equals(string wanted, string got, string message) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public static void Equals(string wanted, string got) | ||
{ | ||
if (wanted == got) | ||
return; | ||
throw new UUnitAssertException(wanted, got); | ||
} | ||
|
||
public static void Equals(int wanted, int got, string message) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public static void Equals(int wanted, int got) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got); | ||
} | ||
|
||
public static void Equals(double wanted, double got, double precision) | ||
{ | ||
if (Math.Abs(wanted - got) < precision) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got); | ||
} | ||
|
||
public static void Equals(double wanted, double got) | ||
{ | ||
Equals(wanted, got, DEFAULT_DOUBLE_PRECISION); | ||
} | ||
|
||
public static void Equals(char wanted, char got) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got); | ||
} | ||
|
||
public static void Equals(object wanted, object got, string message) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public new static void Equals(object wanted, object got) | ||
{ | ||
if (wanted == got) | ||
{ | ||
return; | ||
} | ||
throw new UUnitAssertException(wanted, got); | ||
} | ||
} | ||
} | ||
/* | ||
* UUnit system from UnityCommunity | ||
* Heavily modified | ||
* 0.4 release by pboechat | ||
* http://wiki.unity3d.com/index.php?title=UUnit | ||
* http://creativecommons.org/licenses/by-sa/3.0/ | ||
*/ | ||
|
||
using System; | ||
|
||
namespace PlayFab.UUnit | ||
{ | ||
public static class UUnitAssert | ||
{ | ||
public const double DEFAULT_DOUBLE_PRECISION = 0.000001; | ||
|
||
public static void Skip() | ||
{ | ||
throw new UUnitSkipException(); | ||
} | ||
|
||
public static void Fail(string message = null) | ||
{ | ||
if (string.IsNullOrEmpty(message)) | ||
message = "fail"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void True(bool boolean, string message = null) | ||
{ | ||
if (boolean) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: true, Actual: false"; | ||
throw new UUnitAssertException(true, false, message); | ||
} | ||
|
||
public static void False(bool boolean, string message = null) | ||
{ | ||
if (!boolean) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: false, Actual: true"; | ||
throw new UUnitAssertException(true, false, message); | ||
} | ||
|
||
public static void NotNull(object something, string message = null) | ||
{ | ||
if (something != null) | ||
return; // Success | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Null object"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void Null(object something, string message = null) | ||
{ | ||
if (something == null) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Not null object"; | ||
throw new UUnitAssertException(message); | ||
} | ||
|
||
public static void Equals(string wanted, string got, string message = null) | ||
{ | ||
if (wanted == got) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: " + wanted + ", Actual: " + got; | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public static void Equals(int wanted, int got, string message = null) | ||
{ | ||
if (wanted == got) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: " + wanted + ", Actual: " + got; | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public static void Equals(double wanted, double got, double precision = DEFAULT_DOUBLE_PRECISION, string message = null) | ||
{ | ||
if (Math.Abs(wanted - got) < precision) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: " + wanted + ", Actual: " + got; | ||
throw new UUnitAssertException(wanted, got, message); | ||
} | ||
|
||
public static void Equals(object wanted, object got, string message = null) | ||
{ | ||
if (wanted == got) | ||
return; | ||
|
||
if (string.IsNullOrEmpty(message)) | ||
message = "Expected: " + wanted + ", Actual: " + got; | ||
throw new UUnitAssertException(wanted, got, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,43 @@ | ||
/* | ||
* UUnit system from UnityCommunity | ||
* Heavily modified | ||
* 0.4 release by pboechat | ||
* http://wiki.unity3d.com/index.php?title=UUnit | ||
* http://creativecommons.org/licenses/by-sa/3.0/ | ||
*/ | ||
|
||
using System; | ||
|
||
namespace PlayFab.UUnit | ||
{ | ||
/// <summary> | ||
/// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. | ||
/// The only information shown will be the "skipped" notification | ||
/// </summary> | ||
public class UUnitSkipException : Exception { } | ||
|
||
/// <summary> | ||
/// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. | ||
/// The traceback and message will automatically be displayed as a failure | ||
/// </summary> | ||
public class UUnitAssertException : Exception | ||
{ | ||
public object expected; | ||
public object received; | ||
public string message; | ||
|
||
public UUnitAssertException(string message) | ||
: base(message) | ||
{ | ||
this.message = message; | ||
} | ||
|
||
public UUnitAssertException(object expected, object received, string message) | ||
: base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") | ||
{ | ||
this.expected = (expected == null) ? "null" : expected; | ||
this.received = (received == null) ? "null" : received; | ||
this.message = (message == null) ? "" : message; | ||
} | ||
|
||
public UUnitAssertException(object expected, object received) | ||
: base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received) | ||
{ | ||
this.expected = (expected == null) ? "null" : expected; | ||
this.received = (received == null) ? "null" : received; | ||
} | ||
} | ||
} | ||
/* | ||
* UUnit system from UnityCommunity | ||
* Heavily modified | ||
* 0.4 release by pboechat | ||
* http://wiki.unity3d.com/index.php?title=UUnit | ||
* http://creativecommons.org/licenses/by-sa/3.0/ | ||
*/ | ||
|
||
using System; | ||
|
||
namespace PlayFab.UUnit | ||
{ | ||
/// <summary> | ||
/// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. | ||
/// The only information shown will be the "skipped" notification | ||
/// </summary> | ||
public class UUnitSkipException : Exception { } | ||
|
||
/// <summary> | ||
/// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. | ||
/// The traceback and message will automatically be displayed as a failure | ||
/// </summary> | ||
public class UUnitAssertException : Exception | ||
{ | ||
public object expected; | ||
public object received; | ||
public string message; | ||
|
||
public UUnitAssertException(string message) | ||
: base(message) | ||
{ | ||
this.message = message; | ||
} | ||
|
||
public UUnitAssertException(object expected, object received, string message) | ||
: base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") | ||
{ | ||
this.expected = (expected == null) ? "null" : expected; | ||
this.received = (received == null) ? "null" : received; | ||
this.message = (message == null) ? "" : message; | ||
} | ||
} | ||
} |
Oops, something went wrong.