/// <summary> /// Initializes a new instance of the <see cref="MongoTimeoutPersister"/> class. /// </summary> /// <param name="mongoFactory"> /// The mongo factory. /// </param> public MongoTimeoutPersister(MongoDatabaseFactory mongoFactory) { Contract.Requires<ArgumentNullException>(mongoFactory != null); this.mongoDatabase = mongoFactory.GetDatabase(); this.EnsureTimeoutIndexes(); }
public void GetTest(MongoDatabaseFactory factory, byte[] data) { var st = new MemoryStream(data); var key = Guid.NewGuid().ToString(); factory.GetDatabase().GridFS.Upload(st, key); var sut = new MongoGridFSDataBus(factory); var resultStream = sut.Get(key); var result = new byte[data.Length]; resultStream.Read(result, 0, data.Length); resultStream.Length.Should().Be(data.Length); result.Should().BeEquivalentTo(data); }
public void PutTest(MongoDatabaseFactory factory, byte[] data) { var sut = new MongoGridFSDataBus(factory); var input = new MemoryStream(data); var key = sut.Put(input, TimeSpan.FromDays(1)); var gfs = factory.GetDatabase().GridFS.OpenRead(key); var result = new byte[data.Length]; gfs.Read(result, 0, data.Length); gfs.Length.Should().Be(data.Length); result.Should().BeEquivalentTo(data); }
/// <summary> /// Initializes a new instance of the <see cref="MongoGridFSDataBus"/> class. /// </summary> /// <param name="mongoFactory"> /// The MongoDB factory. /// </param> public MongoGridFSDataBus(MongoDatabaseFactory mongoFactory) { Contract.Requires<ArgumentNullException>(mongoFactory != null, "mongoFactory != null"); this.gridFS = mongoFactory.GetDatabase().GridFS.AssumedNotNull(); }
/// <summary> /// Initializes a new instance of the <see cref="MongoSubscriptionPersister"/> class. /// Initializes a new instance of the <see cref="MongoSubscriptionStorage"/> class. /// </summary> /// <param name="mongoFactory"> /// The MongoDB factory. /// </param> public MongoSubscriptionPersister(MongoDatabaseFactory mongoFactory) { Contract.Requires<ArgumentNullException>(mongoFactory != null); this.mongoDatabase = mongoFactory.GetDatabase(); }