public async Task Delete()
        {
            await uc.SignIn();

            await Create();

            var  storages = sc.GetStorages();
            bool result   = sc.Delete(storages.LastOrDefault().Name);

            Assert.IsTrue(result);
        }
Пример #2
0
        public async Task DeleteStorageTestAsync()
        {
            // Arrange
            Mock <Storage>    mockStorage = new Mock <Storage>();
            StorageController controller  = new StorageController(mockStorageService.Object);

            // Act
            var result = await controller.Delete(await StorageTestHelper.GetStorageCreateNormal());

            var okResult = Assert.IsType <OkObjectResult>(result);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            mockStorageService.Verify(
                mock => mock.Delete(mockStorage.Object), Times.Never());
        }
 private void Menu_MenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e, int position)
 {
     if (e.Item.ItemId == Resource.Id.action_delete)
     {
         PasswordDialogFragment dialog = new PasswordDialogFragment((Activity)context);
         dialog.Func = () =>
         {
             StorageController storageController = new StorageController();
             bool result = storageController.Delete(storages[position].Name);
             if (result)
             {
                 StorageChange(this, new EventArgs());
                 Toast.MakeText(context, "Хранилище " + storages[position].Name + " удалено", ToastLength.Long).Show();
                 return(new Task <bool>(() => true));
             }
             else
             {
                 Toast.MakeText(context, "Неудача", ToastLength.Long).Show();
                 return(new Task <bool>(() => false));
             }
         };
         dialog.Show();
     }
     else if (e.Item.ItemId == Resource.Id.action_change)
     {
         ChangeKeyDialogFragment dialog = new ChangeKeyDialogFragment((Activity)context, storages[position].Name);
         dialog.Func = () =>
         {
             Toast.MakeText(context, "Ключ успешно изменен", ToastLength.Long).Show();
             return(true);
         };
         dialog.Show();
     }
     else if (e.Item.ItemId == Resource.Id.action_connect)
     {
         KeyDialogFragment dialog = new KeyDialogFragment((Activity)context, storages[position].Name);
         dialog.Func = () =>
         {
             EnterKey(this, new EventArgs());
             Toast.MakeText(context, "Вы вошли в хранилище", ToastLength.Long).Show();
             return(true);
         };
         dialog.Show();
     }
 }
Пример #4
0
        public async Task Delete_Storage_From_Database()
        {
            // Arrange
            var storage = new Storage()
            {
                Id = 1, City = "Lviv", Street = "Rubchaka, 56"
            };
            var model = new CreateStorageView()
            {
                City = storage.City, Street = storage.Street
            };

            // Act
            await controller.Create(model);

            await controller.Delete(context.Storages.First().Id);

            // Assert
            Assert.AreEqual(0, context.Storages.Count());
        }