public void get_with_json() { var serializer = new JilSerializer(); var target = new Target(); var json = serializer.ToJson(target); var map = new NulloIdentityMap(serializer); var target2 = map.Get<Target>(target.Id, json); target2.Id.ShouldBe(target.Id); }
public void lazy_get_hit() { var serializer = new JilSerializer(); var target = new Target(); var json = serializer.ToJson(target); var map = new NulloIdentityMap(serializer); var target2 = map.Get<Target>(target.Id, () => new FetchResult<Target>(target, json)); target2.Id.ShouldBe(target.Id); }
public static Target Random(bool deep = false) { var target = new Target(); target.String = _strings[_random.Next(0, 10)]; target.AnotherString = _otherStrings[_random.Next(0, 10)]; target.Number = _random.Next(); target.Float = float.Parse(_random.NextDouble().ToString()); target.NumberArray = new[] {_random.Next(0, 10), _random.Next(0, 10), _random.Next(0, 10)}; switch (_random.Next(0, 2)) { case 0: target.Color = Colors.Blue; break; case 1: target.Color = Colors.Green; break; default: target.Color = Colors.Red; break; } target.Long = 100*_random.Next(); target.Double = _random.NextDouble(); target.Long = _random.Next()*10000; target.Date = DateTime.Today.AddDays(_random.Next(1, 100)); if (deep) { target.Inner = Random(); var number = _random.Next(1, 10); target.Children = new Target[number]; for (int i = 0; i < number; i++) { target.Children[i] = Random(); } } return target; }