Beispiel #1
0
        public void Add <T>(T item)
            where T : IEntity
        {
            MockTable <IEntity> table = GetTypeTable(typeof(T));

            table.Add(item);
        }
Beispiel #2
0
        public bool Exists <T>(T item)
            where T : IEntity
        {
            MockTable <IEntity> table = GetTypeTable(typeof(T));

            return(table.Exists(item.EntityId));
        }
Beispiel #3
0
        private MockTable <IEntity> GetTypeTable(Type type)
        {
            MockTable <IEntity> table;

            if (!Tables.TryGetValue(type, out table))
            {
                table        = new MockTable <IEntity>();
                Tables[type] = table;
            }
            return(table);
        }
Beispiel #4
0
        static public IEnumerable <T> Where <T>(
            this MockTable <T> items, Predicate <T> func)
            where T : IEntity
        {
            if (func == null)
            {
                throw new ArgumentNullException(
                          "Predicate 'func' should not be null");
            }

            foreach (T item in items)
            {
                if (func(item))
                {
                    yield return(item);
                }
            }
        }