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
[Serializable] | |
public class CmsModel : Model | |
{ | |
private IDictionary<Guid, Page> _pages; | |
private Dictionary<string, Menu> _menus; | |
public CmsModel() | |
{ | |
_pages = new Dictionary<Guid, Page>(); | |
_menus = new Dictionary<string, Menu>(); |
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
[ExpectedException(typeof(InvalidOperationException))] | |
[TestMethod()] | |
public void RemovePage_fails_unless_page_exists() | |
{ | |
var target = new CmsModel(); | |
target.RemovePage(Guid.NewGuid()); | |
} | |
[TestMethod()] |
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
[Serializable] | |
public class RemovePageCommand : Command<CmsModel> | |
{ | |
public readonly Guid PageId; | |
public RemovePageCommand(Guid pageId) | |
{ | |
PageId = pageId; | |
} |
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
[Serializable] | |
public class PutPageCommand : Command<CmsModel> | |
{ | |
public readonly Page Page; | |
public PutPageCommand(Page page) | |
{ | |
if (page == null) throw new ArgumentNullException("page"); | |
Page = page; |
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
[Serializable] | |
public class CmsModel : Model | |
{ | |
private IDictionary<Guid, Page> _pages; | |
public CmsModel() | |
{ | |
_pages = new Dictionary<Guid, Page>(); | |
} | |
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
[Serializable] | |
public class Page | |
{ | |
public readonly Guid Id; | |
public readonly DateTime Created; | |
public string Title { get; set; } | |
public string Contents { get; set; } | |
public Page(Guid id, DateTime created) |
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
[TestMethod()] | |
public void can_add_entity() | |
{ | |
var engine = Engine.LoadOrCreate<MyRelationalModel>(); | |
//Create the entity you want to insert | |
var category = new Category{ Name = "Beverages"}; | |
//Create a generic command | |
var addCommand = new AddEntityCommand(category); |
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
[Serializable] | |
public class MyRelationalModel : RelationalModel | |
{ | |
public MyRelationalModel() | |
{ | |
AddSetOf<Category>(); | |
AddSetOf<User>(); | |
AddSetOf<Task>(); | |
} | |
} |
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
[Serializable] | |
public class Category | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} | |
[Serializable] | |
public class User | |
{ |
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
public class Program | |
{ | |
public static int CountCustomersQuery(Dictionary<object,object> docs) | |
{ | |
return docs.OfType<Customer>().Count(); | |
} | |
public static void Main(string[] args) | |
{ | |
//Loads or creates a new database at the default location |