public static void StubPersistence(this CustomAutoFixture fixture) { fixture.Inject((IUnitOfWork)Substitute.ForPartsOf <UnitOfWork_Fake>()); fixture.Entities = new List <object>(); fixture.StubRepositories(); }
public void SetUp() { _fixture = new CustomAutoFixture(); _expectedContextManageCount = _hasCurrentContext ? 0 : 1; _contextService = _fixture.Freeze <IContextService <DbContext_Fake> >(); _dbSetService = _fixture.Freeze <IDbSetService <DbContext_Fake, Foo> >(); _context = new DbContext_Fake(); _contextService.HasCurrentContext().Returns(_hasCurrentContext); _contextService.InitContext().Returns(_context); _contextService.GetCurrentContext().Returns(_context); _expectedEntity = _fixture.Create <Foo>(); _dbSet = CreateDbSetSubstitute(_expectedEntity); _dbSet.FindAsync(_expectedEntity.FooId).Returns(_expectedEntity); _dbSetService.GetDbSet(Arg.Any <DbContext_Fake>()) .Returns(_dbSet); _sut = _fixture.Create <ContextRepository <DbContext_Fake, Foo> >(); }
public void SetUp() { _fixture = new CustomAutoFixture(); _expectedContextManageCount = _hasCurrentContext ? 0 : 1; _contextService = _fixture.Freeze <IContextService <DbContext_Fake> >(); _dbSetService = _fixture.Freeze <IDbSetService <DbContext_Fake, Foo> >(); _flushService = _fixture.Freeze <IFlushService <DbContext_Fake> >(); _context = new DbContext_Fake(); _contextService.HasCurrentContext().Returns(_hasCurrentContext); _contextService.InitContext().Returns(_context); _contextService.GetCurrentContext().Returns(_context); _dbSet = Substitute.For <DbSet <Foo>, IQueryable <Foo> >(); _dbSetService.GetDbSet(Arg.Any <DbContext_Fake>()) .Returns(_dbSet); _sut = _fixture.Create <ContextRepository <DbContext_Fake, Foo> >(); _foo = _fixture.Create <Foo>(); }
private static void StubRepositories(this CustomAutoFixture fixture) { var entityTypes = typeof(BlogContext).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(p => p.PropertyType.Name == "DbSet`1" && p.PropertyType.GenericTypeArguments.Length == 1) .Select(p => p.PropertyType.GenericTypeArguments[0]); foreach (var entityType in entityTypes) { var method = typeof(FixtureExtensions).GetMethod(nameof(StubRepository), BindingFlags.Static | BindingFlags.NonPublic); var genericMethod = method.MakeGenericMethod(entityType); genericMethod.Invoke(null, new object[] { fixture, fixture.Entities }); } }
public void SetUp() { _fixture = new CustomAutoFixture(); _context = new DbContext_Fake(); _contextService = _fixture.Freeze <IContextService <DbContext_Fake> >(); _contextService.HasCurrentContext().Returns(false); _contextService.InitContext().Returns(_context); _contextService.GetCurrentContext().Returns(_context); _contextFlushService = _fixture.Freeze <IContextFlushService <DbContext_Fake> >(); _sut = CreateSut(_transactionType); }
public void SetUp() { _fixture = new CustomAutoFixture(); _context = new DbContext_Fake(); _contextService = _fixture.Freeze <IContextService <DbContext_Fake> >(); _contextService.HasCurrentContext().Returns(false); _contextService.InitContext().Returns(_context); _contextService.GetCurrentContext().Returns(_context); _databaseFacade = (DatabaseFacade_Fake)_context.Database; _sut = _fixture.Create <DbContextTransactionUnitOfWork <DbContext_Fake> >(); }
public void SetUp() { _fixture = new CustomAutoFixture(); _sut = _fixture.Create <NoFlushService <DbContext_Fake> >(); }
public void SetUp() { _fixture = new CustomAutoFixture(); _sut = _fixture.Create <ContextRepository <DbContext_Fake, Foo> >(); }
public void SetUp() { _fixture = new CustomAutoFixture(); _fixture.StubPersistence(); }
public void SetUp() { _fixture = new CustomAutoFixture(); }
public DatabaseFacade_Fake(DbContext context) : base(context) { _fixture = new CustomAutoFixture(); Transaction = _fixture.Create <IDbContextTransaction>(); }