public async void SaveIsIncompleteEnsureAllPendingOperationsAreCancelledStream() { var store = (FilesStore)filesStore; using (var session = filesStore.OpenAsyncSession()) { var fileStream = CreateUniformFileStream(128); session.RegisterUpload("test2.file", fileStream); session.RegisterUpload("test1.file", 128, x => { for (byte i = 0; i < 60; i++) { x.WriteByte(i); } }); session.RegisterRename("test2.file", "test3.file"); TaskAssert.Throws <BadRequestException>(() => session.SaveChangesAsync()); var shouldExist = await session.LoadFileAsync("test2.file"); Assert.NotNull(shouldExist); var shouldNotExist = await session.LoadFileAsync("test3.file"); Assert.Null(shouldNotExist); } }
public void EnsureMaxNumberOfRequestsPerSessionIsHonored() { var store = (FilesStore)filesStore; store.Conventions.MaxNumberOfRequestsPerSession = 0; using (var session = filesStore.OpenAsyncSession()) { TaskAssert.Throws <InvalidOperationException>(() => session.LoadFileAsync("test1.file")); TaskAssert.Throws <InvalidOperationException>(() => session.DownloadAsync("test1.file")); Assert.Throws <InvalidOperationException>(() => session.RegisterFileDeletion("test1.file")); Assert.Throws <InvalidOperationException>(() => session.RegisterRename("test1.file", "test2.file")); Assert.Throws <InvalidOperationException>(() => session.RegisterUpload("test1.file", CreateUniformFileStream(128))); } }
public void UploadActionWritesIncompleteStream() { var store = (FilesStore)filesStore; using (var session = filesStore.OpenAsyncSession()) { session.RegisterUpload("test1.file", 128, x => { for (byte i = 0; i < 60; i++) { x.WriteByte(i); } }); TaskAssert.Throws <BadRequestException>(() => session.SaveChangesAsync()); } }
public async void CanUseSingleOrDefault() { var store = this.NewStore(); using (var session = store.OpenAsyncSession()) { session.RegisterUpload("test.file", CreateUniformFileStream(600)); session.RegisterUpload("test.fil", CreateUniformFileStream(150)); session.RegisterUpload("test.fi", CreateUniformFileStream(16)); session.RegisterUpload("test.f", CreateUniformFileStream(330)); await session.SaveChangesAsync(); Assert.NotNull(session.Query().WhereGreaterThan(x => x.TotalSize, 550).SingleOrDefaultAsync().Result); Assert.Null(session.Query().WhereGreaterThan(x => x.TotalSize, 700).SingleOrDefaultAsync().Result); TaskAssert.Throws <InvalidOperationException>(() => session.Query().WhereGreaterThan(x => x.TotalSize, 150).SingleOrDefaultAsync()); } }
public void UploadActionWritesIncompleteWithErrorStream() { var store = (FilesStore)filesStore; using (var session = filesStore.OpenAsyncSession()) { session.RegisterUpload("test1.file", 128, x => { for (byte i = 0; i < 60; i++) { x.WriteByte(i); } // We are throwing to break the upload. RavenFS client should detect this case and cancel the upload. throw new Exception(); }); TaskAssert.Throws <BadRequestException>(() => session.SaveChangesAsync()); } }