Exemple #1
0
        public void Given()
        {
            var dbSet = new FakeDbSet <MyEntity>();

            MyEntity[] myEntities = { new MyEntity {
                                          Id = 1
                                      }, new MyEntity{
                                          Id = 2
                                      } };
            myEntities.ToList().ForEach(me => dbSet.Add(me));

            dbContext = A.Fake <IDbConctext>();
            A.CallTo(() => dbContext.Set <MyEntity>()).Returns(dbSet);

            sut = new Repository.Repository(dbContext);
        }
Exemple #2
0
 public T GetById <T>(int id) where T : class, IHaveId
 {
     return(dbContext.Set <T>().Single(entity => entity.Id == id));
 }