예제 #1
0
        public async Task Cleans_up_obsolete_operations()
        {
            await AddTablesAsync();

            var existingOperations = new List <NubeOperation>()
            {
                new NubeOperation()
                {
                    ItemId = "otherId", Type = OperationType.Modified
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, Type = OperationType.Deleted
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, Type = OperationType.Modified
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, Type = OperationType.Modified
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, Type = OperationType.Added
                },
            };
            var expectedOperations = existingOperations.Skip(2).ToList();

            DataStore.GetOperationsAsync().Returns(existingOperations.AsQueryable());

            await NubeClient.DeleteAsync(Item);

            Assert.Equal(expectedOperations, RemovedOperations);
        }
        public async Task Does_not_clean_up_delete_operations_from_different_tables()
        {
            await AddTablesAsync();

            var existingOperations = new List <NubeOperation>()
            {
                new NubeOperation()
                {
                    ItemId = "otherId", TableName = "OtherTable", Type = OperationType.Modified
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, TableName = "OtherTable", Type = OperationType.Deleted
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, TableName = "OtherTable", Type = OperationType.Modified
                },
                new NubeOperation()
                {
                    ItemId = Item.Id, TableName = "OtherTable", Type = OperationType.Added
                },
            };

            DataStore.GetOperationsAsync().Returns(existingOperations.AsQueryable());

            await NubeClient.DeleteAsync(Item);

            Assert.Empty(RemovedOperations);
        }
예제 #3
0
 private async void Delete_Button_Clicked(object sender, EventArgs e)
 {
     if (sender is Button button && button.BindingContext is TodoItem item)
     {
         await _nubeClient.DeleteAsync(item);
         await RefreshItemsAsync();
     }
 }
예제 #4
0
        public async Task Does_not_track_the_delete_when_change_tracker_is_disabled()
        {
            await AddTablesAsync();

            DataStore.DeleteAsync(Arg.Any <TestItem>()).Returns(true);

            await NubeClient.DeleteAsync(Item, true);

            await ChangeTracker.DidNotReceive().TrackDeleteAsync(Arg.Any <TestItem>());
        }
예제 #5
0
        public async Task Deletes_the_item_from_the_store()
        {
            await AddTablesAsync();

            DataStore.DeleteAsync(Arg.Any <TestItem>()).Returns(true);

            await NubeClient.DeleteAsync(Item);

            await DataStore.Received().DeleteAsync(Item);
        }
예제 #6
0
        public async Task Tracks_the_delete()
        {
            await AddTablesAsync();

            DataStore.DeleteAsync(Arg.Any <TestItem>()).Returns(true);

            await NubeClient.DeleteAsync(Item);

            await ChangeTracker.Received().TrackDeleteAsync(Item);
        }
예제 #7
0
        public async Task Throws_when_item_id_is_null()
        {
            await AddTablesAsync();

            Item.Id = null;

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await NubeClient.DeleteAsync(Item));

            Assert.Equal("Cannot delete item without id", ex.Message);
        }
예제 #8
0
        public async Task Checks_if_table_is_valid()
        {
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await NubeClient.DeleteAsync(Item));

            Assert.Equal("Table TestItem is not registered in the nube client", ex.Message);
        }
예제 #9
0
        public async Task Throws_when_store_fails()
        {
            DataStore.DeleteAsync(Arg.Any <TestItem>()).Returns(false);
            await AddTablesAsync();

            var ex = await Assert.ThrowsAsync <StoreOperationFailedException>(async() => await NubeClient.DeleteAsync(Item));

            Assert.Equal("Could not delete item", ex.Message);
        }
예제 #10
0
        public async Task Throws_when_operations_cannot_be_stored()
        {
            await AddTablesAsync();

            DataStore.AddOperationsAsync(Arg.Any <NubeOperation[]>()).Returns(false);

            var ex = await Assert.ThrowsAsync <StoreOperationFailedException>(async() => await NubeClient.DeleteAsync(Item));

            Assert.Equal($"Could not save delete operation for item {Item.Id}", ex.Message);
        }