Exemple #1
0
        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);
        }
Exemple #2
0
        public void GetTest(MongoDatabaseFactory factory, byte[] data)
        {
            var gridFsBucket = new GridFSBucket(factory.GetDatabase());
            var key          = gridFsBucket.UploadFromBytes(Guid.NewGuid().ToString(), data);

            var sut          = new MongoGridFSDataBus(factory);
            var resultStream = sut.Get(key.ToString()).Result;

            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);
        }
        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);
        }