Ejemplo n.º 1
0
        public void SetUp()
        {
            _driver      = Substitute.For <IDriver>();
            _session     = Substitute.For <IAsyncSession>();
            _transaction = Substitute.For <IAsyncTransaction>();

            _repository = new GraphRepository(new GraphDbSettingsBuilder()
                                              .Build(),
                                              new CypherBuilderFactory(),
                                              _driver);

            _driver
            .AsyncSession()
            .Returns(_session);

            _session
            .When(_ => _.WriteTransactionAsync(Arg.Any <Func <IAsyncTransaction, Task> >()))
            .Do(_ => _.ArgAt <Func <IAsyncTransaction, Task> >(0).Invoke(_transaction));

            _session
            .When(_ => _.ReadTransactionAsync(Arg.Any <Func <IAsyncTransaction, Task <List <IRecord> > > >()))
            .Do(_ => _.ArgAt <Func <IAsyncTransaction, Task <List <IRecord> > > >(0).Invoke(_transaction));
        }