forked from dynamicexpresso/DynamicExpresso
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests refactoring + typeof operator
- Loading branch information
1 parent
afc14f5
commit c3dceae
Showing
14 changed files
with
934 additions
and
730 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
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,55 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace DynamicExpresso.UnitTest | ||
{ | ||
[TestClass] | ||
public class ConstructorTest | ||
{ | ||
[TestMethod] | ||
public void New_Of_Base_Type() | ||
{ | ||
var target = new Interpreter(); | ||
|
||
Assert.AreEqual(new DateTime(2015, 1, 24), target.Eval("new DateTime(2015, 1, 24)")); | ||
Assert.AreEqual(new string('a', 10), target.Eval("new string('a', 10)")); | ||
} | ||
|
||
[TestMethod] | ||
public void New_Of_Custom_Type() | ||
{ | ||
var target = new Interpreter(); | ||
|
||
target.Using(typeof(Uri)); | ||
|
||
Assert.AreEqual(new Uri("http://www.google.com"), target.Eval("new Uri(\"http://www.google.com\")")); | ||
} | ||
|
||
[TestMethod] | ||
public void New_And_Member_Access() | ||
{ | ||
var target = new Interpreter(); | ||
|
||
Assert.AreEqual(new DateTime(2015, 1, 24).Month, target.Eval("new DateTime(2015, 1, 24).Month")); | ||
Assert.AreEqual(new DateTime(2015, 1, 24).Month + 34, target.Eval("new DateTime( 2015, 1, 24).Month + 34")); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ParseException))] | ||
public void Constructor_invocation_without_new_is_not_supported() | ||
{ | ||
var target = new Interpreter(); | ||
|
||
target.Parse("DateTime(2010, 5, 23)"); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ParseException))] | ||
public void Unknown_New_Type_Is_Not_Supported() | ||
{ | ||
var target = new Interpreter(); | ||
|
||
target.Parse("new unkkeyword()"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.