-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
4e31537
commit 234541e
Showing
36 changed files
with
417 additions
and
117 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
2 changes: 1 addition & 1 deletion
2
src/StubGenerator.Test/Dto/PersonDto.cs → src/StubGenerator.Test.Models/PersonDto.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace StubGenerator.Test.Dto | ||
namespace StubGenerator.Test.Models | ||
{ | ||
public class PersonDto | ||
{ | ||
|
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.Collections.Generic; | ||
|
||
namespace StubGenerator.Test.Models | ||
{ | ||
public class RestApiResult | ||
{ | ||
public RestApiResult() | ||
{ | ||
Links = new List<LinkInfo>(); | ||
} | ||
public List<LinkInfo> Links { get; set; } | ||
} | ||
|
||
|
||
public class LinkInfo | ||
{ | ||
public string Href { get; set; } | ||
public string Rel { get; set; } | ||
public string Method { get; set; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/StubGenerator.Test.Models/StubGenerator.Test.Models.csproj
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,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
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 was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
....Core/Caching/DefaultCacheKeyGenerator.cs → ...ching/DefaultStubTypeCacheKeyGenerator.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
7 changes: 7 additions & 0 deletions
7
src/StubMiddleware.Core/Caching/IStubTypeCacheKeyGenerator.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,7 @@ | ||
namespace StubGenerator.Caching | ||
{ | ||
public interface IStubTypeCacheKeyGenerator | ||
{ | ||
string GenerateKey<T>(); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace StubGenerator.Core | ||
{ | ||
public interface IStubDataMappingProfile | ||
{ | ||
IEnumerable<IStubDataMap> Conventions { get; } | ||
} | ||
} |
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,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace StubGenerator.Core | ||
{ | ||
public interface IStubManager | ||
{ | ||
IList<T> CreateListOfSize<T>(int size) where T : class, new(); | ||
T CreateNew<T>() where T : class, new(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/StubMiddleware.Core/Core/FakeDataType.cs → src/StubMiddleware.Core/Core/StubDataType.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace StubGenerator.Core | ||
{ | ||
public enum FakeDataType | ||
public enum StubDataType | ||
{ | ||
DomainName, | ||
DomainSuffix, | ||
|
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,58 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace StubGenerator.Core | ||
{ | ||
public static class StubManagerExtensions | ||
{ | ||
private static Type LoadType(string typeName) | ||
{ | ||
if (string.IsNullOrWhiteSpace(typeName)) | ||
{ | ||
throw new ArgumentException("message", nameof(typeName)); | ||
} | ||
var result = Type.GetType(typeName); | ||
if (result == null) | ||
throw new TypeLoadException($"The type '{typeName}' couldn't be loaded"); | ||
return result; | ||
} | ||
|
||
public static object InvokeCreateNew(this IStubManager stubManager, string typeName) | ||
{ | ||
if (stubManager == null) | ||
{ | ||
throw new ArgumentNullException(nameof(stubManager)); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(typeName)) | ||
{ | ||
throw new ArgumentException("message", nameof(typeName)); | ||
} | ||
|
||
var type = LoadType(typeName); | ||
|
||
|
||
MethodInfo method = typeof(IStubManager).GetMethod("CreateNew"); | ||
MethodInfo genericMethod = method.MakeGenericMethod(type); | ||
return genericMethod.Invoke(stubManager, null); | ||
} | ||
|
||
public static object InvokeCreateListOfSize(this IStubManager stubManager, string typeName, int size) | ||
{ | ||
if (stubManager == null) | ||
{ | ||
throw new ArgumentNullException(nameof(stubManager)); | ||
} | ||
|
||
if (size <= 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(size), "List Size must be positive number!"); | ||
} | ||
|
||
var type = LoadType(typeName); | ||
MethodInfo method = typeof(IStubManager).GetMethod("CreateListOfSize"); | ||
MethodInfo genericMethod = method.MakeGenericMethod(type); | ||
return genericMethod.Invoke(stubManager, parameters: new object[] { size }); | ||
} | ||
} | ||
} |
Oops, something went wrong.