-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
f02ac4c
commit 0866b9d
Showing
1 changed file
with
44 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,62 @@ | ||
using Xunit; | ||
using System; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using Gridify; | ||
using Xunit; | ||
|
||
namespace Core.Query.Tests | ||
{ | ||
public class GridifyMapperShould | ||
{ | ||
namespace Core.Query.Tests { | ||
public class GridifyMapperShould { | ||
|
||
class TestClass | ||
{ | ||
class TestClass { | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public TestClass ClassProp { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void GenerateMappings() | ||
{ | ||
var sut = new GridifyMapper<TestClass>(); | ||
sut.GenerateMappings(); | ||
Assert.Equal(typeof(TestClass).GetProperties().Count(), sut.Mappings.Count); | ||
Assert.True(sut.Mappings.ContainsKey("Id")); | ||
public void GenerateMappings () { | ||
var sut = new GridifyMapper<TestClass> (); | ||
sut.GenerateMappings (); | ||
Assert.Equal (typeof (TestClass).GetProperties ().Count (), sut.Mappings.Count); | ||
Assert.True (sut.Mappings.ContainsKey ("Id")); | ||
} | ||
|
||
[Fact] | ||
public void CaseSensitivity() | ||
{ | ||
var sut = new GridifyMapper<TestClass>(true); | ||
sut.Mappings.Add("id", q=>q.Id); | ||
|
||
Assert.True(sut.CaseSensitive); | ||
Assert.True(sut.Mappings.ContainsKey("id")); | ||
Assert.False(sut.Mappings.ContainsKey("ID")); | ||
public void CaseSensitivity () { | ||
var sut = new GridifyMapper<TestClass> (true); | ||
sut.Mappings.Add ("id", q => q.Id); | ||
|
||
Assert.True (sut.CaseSensitive); | ||
Assert.True (sut.Mappings.ContainsKey ("id")); | ||
Assert.False (sut.Mappings.ContainsKey ("ID")); | ||
} | ||
|
||
[Fact] | ||
public void AddMap() | ||
{ | ||
var sut = new GridifyMapper<TestClass>(); | ||
sut.AddMap(nameof(TestClass.Name), p => p.Name); | ||
Assert.Single(sut.Mappings); | ||
public void AddMap () { | ||
var sut = new GridifyMapper<TestClass> (); | ||
sut.AddMap (nameof (TestClass.Name), p => p.Name); | ||
Assert.Single (sut.Mappings); | ||
} | ||
|
||
[Fact] | ||
public void RemoveMap() | ||
{ | ||
var sut = new GridifyMapper<TestClass>(); | ||
sut.Mappings.Add("name",q=>q.Name); | ||
sut.Mappings.Add("Id",q=>q.Id); | ||
sut.RemoveMap( nameof(TestClass.Name) ); | ||
Assert.Single(sut.Mappings); | ||
public void RemoveMap () { | ||
var sut = new GridifyMapper<TestClass> (); | ||
sut.Mappings.Add ("name", q => q.Name); | ||
sut.Mappings.Add ("Id", q => q.Id); | ||
sut.RemoveMap (nameof (TestClass.Name)); | ||
Assert.Single (sut.Mappings); | ||
} | ||
|
||
[Fact] | ||
public void GetExpression () { | ||
var sut = new GridifyMapper<TestClass> (); | ||
|
||
Expression<Func<TestClass, object>> expected = Param_0 => (object)Param_0.Name; | ||
var actual = sut.GetExpression ("Name"); | ||
|
||
Assert.IsType (expected.GetType() , actual); | ||
Assert.Equal( expected.Body.ToString() ,actual.Body.ToString()); | ||
|
||
} | ||
} | ||
} | ||
} |