public async Task ReplaceItemAsync_SoftDeleted_ReturnsGone() { // Arrange var id = GetRandomId(); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id).ConfigureAwait(false); var original = MovieServer.GetMovieById(id) !; var expected = ClientMovie.From(original); expected.Title = "Replacement Title"; expected.Rating = "PG-13"; var json = CreateJsonDocument(expected); var table = client.GetRemoteTable("soft"); // Act var exception = await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => soft.ReplaceItemAsync(json)).ConfigureAwait(false); var stored = MovieServer.GetMovieById(id).Clone(); // Assert Assert.Equal(HttpStatusCode.Gone, exception.Response?.StatusCode); Assert.Equal <IMovie>(original, stored); Assert.Equal <ITableData>(original, stored); }
public async Task ReadSoftDeletedItem_ReturnsGoneIfDeleted([CombinatorialValues("soft", "soft_logged")] string table) { var id = GetRandomId(); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id); var response = await MovieServer.SendRequest(HttpMethod.Get, $"tables/{table}/{id}"); await AssertResponseWithLoggingAsync(HttpStatusCode.Gone, response); }
public async Task SoftDeleteItem_GoneWhenDeleted([CombinatorialValues("soft", "soft_logged")] string table) { var id = GetRandomId(); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id); var response = await MovieServer.SendRequest(HttpMethod.Delete, $"tables/{table}/{id}"); await AssertResponseWithLoggingAsync(HttpStatusCode.Gone, response); Assert.Equal(TestData.Movies.Count, MovieServer.GetMovieCount()); var currentEntity = MovieServer.GetMovieById(id) !; Assert.True(currentEntity.Deleted); }
public async Task GetItemAsync_GoneIfSoftDeleted() { // Arrange // Arrange var id = GetRandomId(); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id).ConfigureAwait(false); // Act var exception = await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => soft.GetItemAsync(id)).ConfigureAwait(false); // Assert Assert.NotNull(exception.Request); Assert.NotNull(exception.Response); Assert.Equal(HttpStatusCode.Gone, exception.Response?.StatusCode); }
public async Task DeleteItemAsync_GoneWhenDeleted() { // Arrange var id = GetRandomId(); var item = ClientMovie.From(MovieServer.GetMovieById(id)); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id).ConfigureAwait(false); // Act var exception = await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => soft.DeleteItemAsync(item)).ConfigureAwait(false); // Assert Assert.NotNull(exception.Request); Assert.NotNull(exception.Response); Assert.Equal(HttpStatusCode.Gone, exception.Response?.StatusCode); Assert.Equal(MovieCount, MovieServer.GetMovieCount()); var entity = MovieServer.GetMovieById(id); Assert.True(entity.Deleted); }
public async Task UndeleteItemAsync_WhenDeleted() { // Arrange var id = GetRandomId(); var jsonDocument = CreateJsonDocument(new IdOnly { Id = id }); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id).ConfigureAwait(false); var original = MovieServer.GetMovieById(id); // Act var response = await soft.UndeleteItemAsync(jsonDocument).ConfigureAwait(false); var stored = MovieServer.GetMovieById(id) !; // Assert Assert.False(stored.Deleted); AssertJsonDocumentMatches(stored, response); }
public async Task ReplaceSoftDeleted_ReturnsGone([CombinatorialValues("soft", "soft_logged")] string table) { var id = GetRandomId(); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id); var original = MovieServer.GetMovieById(id) !; var expected = MovieServer.GetMovieById(id) !; expected.Title = "Replacement Title"; expected.Rating = "PG-13"; var response = await MovieServer.SendRequest(HttpMethod.Put, $"tables/{table}/{id}", expected); var stored = MovieServer.GetMovieById(id); await AssertResponseWithLoggingAsync(HttpStatusCode.Gone, response); Assert.Equal <IMovie>(original, stored !); Assert.Equal <ITableData>(original, stored !); }
public async Task UndeleteItemAsync_WhenDeleted() { // Arrange var id = GetRandomId(); var item = new ClientMovie { Id = id }; await MovieServer.SoftDeleteMoviesAsync(x => x.Id == id).ConfigureAwait(false); var original = MovieServer.GetMovieById(id); // Act await soft.UndeleteItemAsync(item).ConfigureAwait(false); var stored = MovieServer.GetMovieById(id) !; // Assert Assert.False(stored.Deleted); Assert.Equal <IMovie>(stored, item); AssertEx.SystemPropertiesMatch(stored, item); }
public async Task DeleteItemAsync_GoneWhenDeleted() { // Arrange var idToDelete = GetRandomId(); var jsonDocument = CreateJsonDocument(new IdOnly { Id = idToDelete }); await MovieServer.SoftDeleteMoviesAsync(x => x.Id == idToDelete).ConfigureAwait(false); var original = MovieServer.GetMovieById(idToDelete); // Act var exception = await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => soft.DeleteItemAsync(jsonDocument)).ConfigureAwait(false); // Assert Assert.NotNull(exception.Request); Assert.NotNull(exception.Response); Assert.Equal(HttpStatusCode.Gone, exception.Response?.StatusCode); Assert.Equal(MovieCount, MovieServer.GetMovieCount()); var entity = MovieServer.GetMovieById(idToDelete); Assert.True(entity.Deleted); }