-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
10 changed files
with
113 additions
and
4 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
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
74 changes: 74 additions & 0 deletions
74
src/FastGenericNew.Tests/Units/GetFastNewTests/ExceptionsTest.cs
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,74 @@ | ||
namespace FastGenericNew.Tests.Units.GetFastNewTests; | ||
|
||
public class ExceptionsTest | ||
{ | ||
[Test()] | ||
public void ExceptionInterface() | ||
{ | ||
try | ||
{ | ||
FastNew.GetCreateInstance<IEnumerable>(typeof(IEnumerable))(); | ||
Assert.Fail("The expected exception is not thrown."); | ||
} | ||
catch (MissingMethodException e) | ||
{ | ||
Assert.IsTrue(e.Message.StartsWith("Cannot create an instance of an interface")); | ||
} | ||
} | ||
|
||
[Test()] | ||
public void ExceptionAbstract() | ||
{ | ||
try | ||
{ | ||
FastNew.GetCreateInstance<Stream>(typeof(Stream))(); | ||
Assert.Fail("The expected exception is not thrown."); | ||
} | ||
catch (MissingMethodException e) | ||
{ | ||
Assert.IsTrue(e.Message.StartsWith("Cannot create an abstract class")); | ||
} | ||
} | ||
|
||
[Test()] | ||
public void ExceptionPLString() | ||
{ | ||
try | ||
{ | ||
FastNew.GetCreateInstance<string>(typeof(string))(); | ||
Assert.Fail("The expected exception is not thrown."); | ||
} | ||
catch (MissingMethodException e) | ||
{ | ||
Assert.IsTrue(e.Message.StartsWith("No match constructor found in type")); | ||
} | ||
} | ||
|
||
[Test()] | ||
public void ExceptionNotFoundNoParameter() | ||
{ | ||
try | ||
{ | ||
FastNew.GetCreateInstance<DemoClassNoParamlessCtor>(typeof(DemoClassNoParamlessCtor))(); | ||
Assert.Fail("The expected exception is not thrown."); | ||
} | ||
catch (MissingMethodException e) | ||
{ | ||
Assert.IsTrue(e.Message.StartsWith("No match constructor found in type")); | ||
} | ||
} | ||
|
||
[Test()] | ||
public void ExceptionNotFoundWithParameter() | ||
{ | ||
try | ||
{ | ||
FastNew.GetCreateInstance<DemoClass, DBNull>(typeof(DemoClass), typeof(DBNull))(DBNull.Value); | ||
Assert.Fail("The expected exception is not thrown."); | ||
} | ||
catch (MissingMethodException e) | ||
{ | ||
Assert.IsTrue(e.Message.StartsWith("No match constructor found in type")); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/FastGenericNew.Tests/Units/GetFastNewTests/ValueType.cs
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,13 @@ | ||
namespace FastGenericNew.Tests.Units.GetFastNewTests; | ||
|
||
public class ValueTypes | ||
{ | ||
[TestCaseSourceGeneric(typeof(TestData), nameof(TestData.CommonValueTypes))] | ||
[Parallelizable(ParallelScope.All)] | ||
public void CommonTypes<T>() | ||
{ | ||
var expected = Activator.CreateInstance<T>(); | ||
var actual = FastNew.GetCreateInstance<T>(typeof(T))(); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
} |