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)).Result; var gridFsBucket = new GridFSBucket(factory.GetDatabase()); var result = gridFsBucket.DownloadAsBytes(ObjectId.Parse(key)); result.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); }