-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FakeFaker checks callee if no module in placeholder (#120)
* Added a method that adds the callee to the match. * Added the StackTraceWrapper class. This is used to check the call stack to see what class called the method. * Injected the IStackTraceWrapper into the FakeFaker class. * Renamed the file. * Instead of throwing errors we just leave the string in place. Updated the tests to make sure we don't throw errors anymore. * F converts #'s to numbers. * Updated the Parse method of the other fakers.
- Loading branch information
Showing
10 changed files
with
201 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Diagnostics; | ||
|
||
namespace FakerDotNet.Wrappers | ||
{ | ||
internal interface IStackTraceWrapper | ||
{ | ||
string GetClassAtFrame(int frameIndex); | ||
} | ||
|
||
internal class StackTraceWrapper : IStackTraceWrapper | ||
{ | ||
public string GetClassAtFrame(int frameIndex) | ||
{ | ||
return new StackTrace() | ||
.GetFrame(frameIndex + 1) | ||
?.GetMethod() | ||
?.ReflectedType | ||
?.Name; | ||
} | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
tests/FakerDotNet.Tests/Wrappers/StackTraceWrapperTests.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,34 @@ | ||
using FakerDotNet.Wrappers; | ||
using NUnit.Framework; | ||
|
||
namespace FakerDotNet.Tests.Wrappers | ||
{ | ||
[TestFixture] | ||
[Parallelizable] | ||
public class StackTraceWrapperTests | ||
{ | ||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_stackTraceWrapper = new StackTraceWrapper(); | ||
} | ||
|
||
private IStackTraceWrapper _stackTraceWrapper; | ||
|
||
[Test] | ||
public void GetClassAtFrame_returns_the_class_at_a_frame_index_plus_one() | ||
{ | ||
var result = _stackTraceWrapper.GetClassAtFrame(0); | ||
|
||
Assert.AreEqual("StackTraceWrapperTests", result); | ||
} | ||
|
||
[Test] | ||
public void GetClassAtFrame_returns_null_if_no_class_at_the_specified_frame_index() | ||
{ | ||
var result = _stackTraceWrapper.GetClassAtFrame(99); | ||
|
||
Assert.IsNull(result); | ||
} | ||
} | ||
} |