void before_each() { seed = new Seed(); GameSchema.CreateSchema(seed); players = new Players(); player1Id = new { Name = "Jane" }.InsertInto("Players"); player2Id = new { Name = "John" }.InsertInto("Players"); game1Id = new { Title = "Mirror's Edge" }.InsertInto("Games"); game2Id = new { Title = "Gears of War" }.InsertInto("Games"); new { PlayerId = player1Id, GameId = game2Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game1Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game2Id }.InsertInto("Library"); sqlQueries = new List<string>(); DynamicRepository.WriteDevLog = true; DynamicRepository.LogSql = new Action<object, string, object[]>( (sender, sql, @params) => { sqlQueries.Add(sql); }); }
void belongs_where_entity_belongs_more_than_one_relation() { before = () => { seed = new Seed(); GameSchema.CreateSchema(seed); players = new Players(); player1Id = new { Name = "Jane" }.InsertInto("Players"); player2Id = new { Name = "John" }.InsertInto("Players"); game1Id = new { Title = "Mirror's Edge" }.InsertInto("Games"); game2Id = new { Title = "Gears of War" }.InsertInto("Games"); new { PlayerId = player1Id, GameId = game2Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game1Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game2Id }.InsertInto("Library"); sqlQueries = new List<string>(); DynamicRepository.WriteDevLog = true; DynamicRepository.LogSql = new Action<object, string, object[]>( (sender, sql, @params) => { sqlQueries.Add(sql); }); allPlayers = players.All(); allPlayers.Include("Library"); allPlayers.Library().Include("Game"); }; it["updates all references that map to the belongs to entity"] = () => { (allPlayers.First().Library().First().Game().Title as object).should_be("Gears of War"); (allPlayers.Last().Library().First().Game().Title as object).should_be("Mirror's Edge"); (allPlayers.Last().Library().Last().Game().Title as object).should_be("Gears of War"); sqlQueries.Count.should_be(3); }; }
void before_each() { CreateSchema(); players = new Players(); new { Name = "Fluff To Ensure Different Id's" }.InsertInto("Players"); player1Id = new { Name = "Jane" }.InsertInto("Players"); player2Id = new { Name = "John" }.InsertInto("Players"); game1Id = new { Title = "Mirror's Edge" }.InsertInto("Games"); game2Id = new { Title = "Gears of War" }.InsertInto("Games"); new { PlayerId = player1Id, GameId = game2Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game1Id }.InsertInto("Library"); }
void cache_access_in_specific_order() { before = () => { GameSchema.CreateSchema(seed); players = new Players(); player1Id = new { Name = "Jane" }.InsertInto("Players"); player2Id = new { Name = "John" }.InsertInto("Players"); game1Id = new { Title = "Mirror's Edge" }.InsertInto("Games"); game2Id = new { Title = "Gears of War" }.InsertInto("Games"); new { PlayerId = player1Id, GameId = game2Id }.InsertInto("Library"); new { PlayerId = player2Id, GameId = game1Id }.InsertInto("Library"); sqlQueries = new List<string>(); DynamicRepository.WriteDevLog = true; DynamicRepository.LogSql = new Action<object, string, object[]>( (sender, sql, @params) => { sqlQueries.Add(sql); }); }; it["in query isn't run if entries are access independently"] = () => { var allPlayers = players.All() as dynamic; (allPlayers as IEnumerable<dynamic>).Count().should_be(2); foreach(var p in allPlayers) { (p.Games() as IEnumerable<dynamic>).Count().should_be(1); } (allPlayers.Games() as IEnumerable<dynamic>).Count().should_be(2); sqlQueries.Count().should_be(3); }; after = () => DynamicRepository.WriteDevLog = false; }