public void InitContext() { var ctx = (Repository as IContextRepository <DbContext>); Assert.NotNull(ctx); var options = CreateNewContextOptions(); Db = new MenuContext(options); MenuTestHelper.PopulateDefaultMenuData(Db); Assert.DoesNotThrow(() => ctx.SetContext(Db)); }
public void InitContext() { var ctx = (_repository as IContextRepository <DbContext>); if (ctx == null) { throw new InvalidCastException("No db Context used"); } Assert.NotNull(ctx); var options = CreateNewContextOptions(); Db = new MenuContext(options); MenuTestHelper.PopulateDefaultMenuData(Db); Assert.DoesNotThrow(() => ctx.SetContext(Db)); }
public void DeleteById() { try { var options = CreateNewContextOptions(); using (var db = new UserBasedMenuContext(options)) { MenuTestHelper.PopulateDefaultMenuDataUserCtx(db); } using (var db = new UserBasedMenuContext(options)) { var repo = new MenuItemUserRelationRepository(db); var item = db.Set <UserMenuItemRelation>().First(); //Удаляем созданный объект Assert.DoesNotThrow(() => repo.Delete(item.Id)); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }