-
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.
FakeDataProvider is implemented, project structure is updated and new…
… conventions are added.
- Loading branch information
1 parent
444284d
commit 03fad72
Showing
49 changed files
with
665 additions
and
379 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
50 changes: 50 additions & 0 deletions
50
src/StubGenerator.Test.Models/ModelWithComplexTypeProperty.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,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace StubGenerator.Test.Models | ||
{ | ||
public class ModelWithComplexTypeProperty | ||
{ | ||
public string ParentString { get; set; } | ||
|
||
public decimal ParentDecimal { get; set; } | ||
|
||
public string HomePhone { get; set; } | ||
|
||
public string MobilePhone { get; set; } | ||
|
||
public int? NullableInteger { get; set; } | ||
|
||
public InnerComplexType ComplexType { get; set; } | ||
|
||
public List<InnerComplexType> CollectionTypeComplex { get; set; } | ||
} | ||
|
||
public class InnerComplexType | ||
{ | ||
public int IntegerProperty { get; set; } | ||
|
||
public string StringProperty { get; set; } | ||
|
||
public DateTime DateTimeProperty { get; set; } | ||
|
||
public EnTestEnum EnumProperty { get; set; } | ||
|
||
public Guid GuidProperty { get; set; } | ||
|
||
public decimal DecimalProperty { get; set; } | ||
|
||
public double DoubleProperty { get; set; } | ||
|
||
public int? NullableIntegerProperty { get; set; } | ||
|
||
public Nullable<int> NullableIntegerProperty2 { get; set; } | ||
} | ||
|
||
public enum EnTestEnum | ||
{ | ||
Option1, | ||
Option2, | ||
Option3 | ||
} | ||
} |
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,12 +1,14 @@ | ||
using StubGenerator.Core; | ||
using System.Reflection; | ||
|
||
namespace StubGenerator.Caching | ||
{ | ||
public interface IStubTypeCache | ||
{ | ||
void Clear(); | ||
StubTypeItem Get<T>(T instance) where T : class; | ||
bool Set<T>(T instance, StubTypeItem stubTypeItem) where T : class; | ||
PropertyInfo[] Get<T>(T instance) where T : class; | ||
PropertyInfo[] GetOrAdd<T>(T instance, PropertyInfo[] propertyInfos) where T : class; | ||
bool Set<T>(T instance, PropertyInfo[] stubTypeItem) where T : class; | ||
bool IsEmpty(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Collections.Concurrent; | ||
using StubGenerator.Core; | ||
using System.Reflection; | ||
|
||
namespace StubGenerator.Caching | ||
{ | ||
public class MemoryStubTypeCache : IStubTypeCache | ||
{ | ||
private readonly ConcurrentDictionary<string, PropertyInfo[]> Cache; | ||
private readonly IStubTypeCacheKeyGenerator _cacheKeyGenerator; | ||
|
||
public MemoryStubTypeCache() | ||
:this(new DefaultStubTypeCacheKeyGenerator()) | ||
{ | ||
} | ||
|
||
public MemoryStubTypeCache(IStubTypeCacheKeyGenerator cacheKeyGenerator) | ||
{ | ||
Cache = new ConcurrentDictionary<string, PropertyInfo[]>(); | ||
_cacheKeyGenerator = cacheKeyGenerator; | ||
} | ||
|
||
public PropertyInfo[] Get<T>(T instance) where T : class | ||
{ | ||
string cacheKey = _cacheKeyGenerator.GenerateKey<T>(); | ||
Cache.TryGetValue(cacheKey, out PropertyInfo[] result); | ||
return result; | ||
} | ||
|
||
public PropertyInfo[] GetOrAdd<T>(T instance, PropertyInfo[] propertyInfos) where T : class | ||
{ | ||
var cacheKey = _cacheKeyGenerator.GenerateKey<T>(); | ||
return Cache.GetOrAdd(cacheKey, i => { return propertyInfos; }); | ||
} | ||
|
||
public bool Set<T>(T instance, PropertyInfo[] stubTypeItem) where T : class | ||
{ | ||
string cacheKey = _cacheKeyGenerator.GenerateKey<T>(); | ||
return Cache.TryAdd(cacheKey, stubTypeItem); | ||
} | ||
|
||
public void Clear() => Cache.Clear(); | ||
|
||
public bool IsEmpty() | ||
{ | ||
return Cache.Count == 0; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.