-
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.
Set types when create Column definitions
Add a MockColumn class to manage ColumnName and ColumnType. Add WithColumns method : `MockTable.WithColumns(("Col1", typeof(int?)));`
- Loading branch information
Showing
11 changed files
with
240 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
||
namespace Apps72.Dev.Data.DbMocker | ||
{ | ||
/// <summary /> | ||
[DebuggerDisplay("Name")] | ||
public class MockColumn | ||
{ | ||
/// <summary /> | ||
public MockColumn() : this(string.Empty, typeof(object)) | ||
{ | ||
} | ||
|
||
/// <summary /> | ||
public MockColumn(string name) : this(name, typeof(object)) | ||
{ | ||
} | ||
|
||
/// <summary /> | ||
public MockColumn(string name, Type type) | ||
{ | ||
this.Name = name; | ||
this.Type = type; | ||
} | ||
|
||
/// <summary /> | ||
public string Name { get; set; } | ||
|
||
/// <summary /> | ||
public Type Type { get; set; } | ||
|
||
/// <summary /> | ||
public static implicit operator string(MockColumn column) | ||
{ | ||
return column.Name; | ||
} | ||
|
||
/// <summary /> | ||
public static implicit operator MockColumn(string name) | ||
{ | ||
return new MockColumn() | ||
{ | ||
Name = name, | ||
Type = typeof(object) | ||
}; | ||
} | ||
|
||
/// <summary /> | ||
public static implicit operator (string Name, Type Type)(MockColumn column) | ||
{ | ||
return (column.Name, column.Type); | ||
} | ||
|
||
/// <summary /> | ||
public static implicit operator MockColumn((string Name, Type Type) column) | ||
{ | ||
return new MockColumn() | ||
{ | ||
Name = column.Name, | ||
Type = column.Type | ||
}; | ||
} | ||
} | ||
|
||
public static class Columns | ||
{ | ||
public static MockColumn[] WithNames(params string[] names) | ||
{ | ||
return names.Select(name => new MockColumn(name)).ToArray(); | ||
} | ||
|
||
public static MockColumn[] WithNames(params (string Name, Type Type)[] columns) | ||
{ | ||
return columns.Select(i => new MockColumn(i.Name, i.Type)).ToArray(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.