public async Task Can_add_async()
 {
     IMongoDatabase  database = MongoForTest.Provider.GetDatabase();
     var             repo     = new ProviderSessionMongoRepository(database);
     ProviderSession session  = BuildDummySession();
     await repo.AddAsync(session);
 }
        public async Task Can_get_previous_returns_null_if_only_same()
        {
            IMongoDatabase  database = MongoForTest.Provider.GetDatabase();
            var             repo     = new ProviderSessionMongoRepository(database);
            ProviderSession session  = BuildDummySession();
            await repo.AddAsync(session);

            var result = await repo.GetPreviousAsync(session);

            result.Should().BeNull();
        }
        public async Task Can_get_by_id()
        {
            IMongoDatabase  database = MongoForTest.Provider.GetDatabase();
            var             repo     = new ProviderSessionMongoRepository(database);
            ProviderSession session  = BuildDummySession();
            await repo.AddAsync(session);

            var result = await repo.GetAsync(session.Id);

            result.Should().BeEquivalentTo(session);
        }
        public async Task Can_get_previous()
        {
            IMongoDatabase  database = MongoForTest.Provider.GetDatabase();
            var             repo     = new ProviderSessionMongoRepository(database);
            ProviderSession session  = BuildDummySession();
            await repo.AddAsync(session);

            ProviderSession session2 = BuildDummySession(Keccak.Zero);
            var             result   = await repo.GetPreviousAsync(session2);

            result.Should().BeEquivalentTo(session);
        }
        public async Task Can_browse_with_query_and_pagination()
        {
            IMongoDatabase  database = MongoForTest.Provider.GetDatabase();
            var             repo     = new ProviderSessionMongoRepository(database);
            ProviderSession session  = BuildDummySession();
            await repo.AddAsync(session);

            var query = new GetProviderSessions();

            query.ConsumerAddress = session.ConsumerAddress;
            query.DepositId       = session.DepositId;
            query.ProviderAddress = session.ProviderAddress;
            query.ConsumerNodeId  = session.ConsumerNodeId;
            query.DataAssetId     = session.DataAssetId;
            query.ProviderNodeId  = session.ProviderNodeId;
            query.Page            = 0;
            query.Results         = 10;
            await repo.BrowseAsync(query);
        }