Exemple #1
0
        private void _rightMenuButton_Clicked(object sender, System.EventArgs e)
        {
            switch (RightMenu)
            {
            case RightMenuIcon.Add:
                AddCommand?.Execute(null);
                break;

            case RightMenuIcon.CustomText:
            case RightMenuIcon.CustomIcon:
                RightMenuCommand?.Execute(null);
                break;

            case RightMenuIcon.Delete:
                DeleteCommand?.Execute(null);
                break;

            case RightMenuIcon.Edit:
                EditCommand?.Execute(null);
                break;

            case RightMenuIcon.Save:
                SaveCommand?.Execute(null);
                break;

            case RightMenuIcon.Settings:
                SettingsCommand?.Execute(null);
                break;
            }
        }
Exemple #2
0
 private void DeleteKeyCommand_Execute(KeyEventArgs e)
 {
     if (e.Key == Key.Delete && SelectedClient != null)
     {
         DeleteCommand.Execute(null);
     }
 }
Exemple #3
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Focusable        = true;
            IsHitTestVisible = true;

            //set the AllowDrop
            if (IsDrawLineDropEnabled)
            {
                this.AllowDrop = true;

                if (this.Content is UIElement)
                {
                    SetContentAllowDrop(this.Content as UIElement);
                }
            }

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete,
                                                        (sender, e) =>
            {
                DeleteCommand.Execute(DataContext);
                DeleteDiagramAndLines();
            },
                                                        (sender, e) =>
            {
                e.CanExecute = DeleteCommand?.CanExecute(DataContext) ?? false;
            }
                                                        ));
        }
        public void When_deleting_item_in_cache_with_time_will_block_cas_operations()
        {
            Cache["foo2"] = new CachedItem();

            var stream  = new MemoryStream();
            var command = new DeleteCommand();

            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };

            stream = GetStreamWithData(buffer);
            var casCommand = new CasCommand();

            casCommand.SetContext(stream);
            casCommand.Init("foo2", "1", "6000", "4", "2");

            casCommand.FinishedExecuting += () => wait.Set();
            casCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_STORED\r\n", ReadAll(6, stream));
        }
Exemple #5
0
        public void DeleteCommand_CheckLogic_SenderNotExists()
        {
            var chatMembers = new List <ChatMember>
            {
                new ChatMember
                {
                    ChatId = "1",
                    Id     = 1,
                    Name   = "Any User Name"
                },
                new ChatMember
                {
                    ChatId = "1",
                    Id     = 2,
                    Name   = "Super User Name"
                }
            };
            var dbProviderMock = GetDbProvider(chatMembers);
            var deleteCommand  = new DeleteCommand(dbProviderMock);
            var context        = new CommandContext("User Name", "1", null);

            var result = deleteCommand.Execute(context);

            Assert.AreEqual("'User Name' отсутствует в списке", result);
            Assert.AreEqual(2, chatMembers.Count);
        }
        public void When_deleting_item_in_cache_with_time_when_item_do_not_exists_should_not_block_add_operations()
        {
            var stream  = new MemoryStream();
            var command = new DeleteCommand();

            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_FOUND\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };

            stream = GetStreamWithData(buffer);
            var addCommand = new AddCommand();

            addCommand.SetContext(stream);
            addCommand.Init("foo2", "1", "6000", "4");

            addCommand.FinishedExecuting += () => wait.Set();
            addCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("STORED\r\n", ReadAll(6, stream));
        }
Exemple #7
0
        public void DeleteCommand_CheckLogic_DeleteUser()
        {
            var chatMembers = new List <ChatMember>
            {
                new ChatMember
                {
                    ChatId = "1",
                    Id     = 1,
                    Name   = "Sender User Name"
                },
                new ChatMember
                {
                    ChatId = "1",
                    Id     = 2,
                    Name   = "User Name"
                }
            };
            var dbProviderMock = GetDbProvider(chatMembers);
            var deleteCommand  = new DeleteCommand(dbProviderMock);
            var context        = new CommandContext("Sender User Name", "1", "User Name");

            var result = deleteCommand.Execute(context);

            Assert.AreEqual("'User Name' удален(а) из списка", result);
            Assert.AreEqual(1, chatMembers.Count);
            Assert.AreEqual("Sender User Name", chatMembers[0].Name);
        }
        public void Deleting_With_Filter_Condition()
        {
            using (_Connection)
            {
                // get expected value
                var expectedCmd = _Connection.CreateCommand();
                expectedCmd.CommandText = @"SELECT COUNT(*) FROM People";

                int numberOfPeopleBeforeDeletion = Convert.ToInt32(expectedCmd.ExecuteScalar());

                if (numberOfPeopleBeforeDeletion == 0)
                {
                    throw new Exception("No people found");
                }

                DeleteCommand <Person> cmd = new DeleteCommand <Person>(_Connection, "People");

                cmd.Filter = new FilterComparison("Id", FilterComparisonOperatorEnum.ExactlyEqual, 4);

                cmd.Execute();

                // check
                var checkCmd = _Connection.CreateCommand();
                checkCmd.CommandText = @"SELECT COUNT(*) FROM People";

                int numberOfPeopleAfterDeletion = Convert.ToInt32(checkCmd.ExecuteScalar());

                Assert.AreEqual(numberOfPeopleBeforeDeletion - 1, numberOfPeopleAfterDeletion);
            }
        }
Exemple #9
0
 private void DeleteButtonOnClicked()
 {
     if (DeleteCommand != null && DeleteCommand.CanExecute(Product))
     {
         DeleteCommand.Execute(Product);
     }
 }
Exemple #10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button)
            {
                switch (button.Name)
                {
                case "buttonEdit":
                    EditCommand?.Execute(null);
                    break;

                case "buttonDelete":
                    DeleteCommand?.Execute(null);
                    break;

                case "buttonCancel":
                    CancelCommand?.Execute(null);
                    break;

                case "buttonSave":
                    SaveCommand?.Execute(null);
                    break;

                case "buttonAdd":
                    AddCommand?.Execute(null);
                    break;
                }
            }
        }
        public MainViewModel()
        {
            IsLoading = Visibility.Collapsed;
            NoDeletedItemsVisibility = Visibility.Collapsed;

            //初始化
            NewToDo             = new ToDo();
            CurrentUser         = new MyerListUser();
            MyToDos             = new ObservableCollection <ToDo>();
            DeletedToDos        = new ObservableCollection <ToDo>();
            CurrentDisplayToDos = MyToDos;
            IsInSortMode        = false;

            SelectedCate = 0;

            CateColor      = App.Current.Resources["DefaultColor"] as SolidColorBrush;
            CateColorLight = App.Current.Resources["DefaultColorLight"] as SolidColorBrush;
            CateColorDark  = App.Current.Resources["DefaultColorDark"] as SolidColorBrush;

            //设置当前页面为 To-Do
            SelectedIndex   = 0;
            TodoIconAlpha   = 1;
            DeleteIconAlpha = 0.3;
            Title           = ResourcesHelper.GetString("ToDoPivotItem");

            //按下Enter后
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.EnterToAdd, act =>
            {
                if (!string.IsNullOrEmpty(NewToDo.Content))
                {
                    OkCommand.Execute(null);
                }
            });

            //完成ToDo
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CheckToDo, act =>
            {
                var id = act.Content;
                CheckCommand.Execute(id);
            });

            //删除To-Do
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.DeleteToDo, act =>
            {
                var id = act.Content;
                DeleteCommand.Execute(id);
            });

            Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.ReaddToDo, act =>
            {
                this.NewToDo = act.Content;
                OkCommand.Execute(false);
            });

            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CompleteSort, async act =>
            {
                await UpdateOrder();
            });
        }
Exemple #12
0
        public void Execute_PassNull_ThrowsArgumentNullException()
        {
            // Arrange
            var command = new DeleteCommand(VocabularyStubFactory.Stub());

            // Assert
            Assert.Throws <ArgumentNullException>(() => command.Execute(null));
        }
        public static int Delete(this DbConnection connection, string tableName, IFilter filterCondition)
        {
            var query = new DeleteCommand <Record>(connection, tableName);

            query.Filter = filterCondition;

            return(query.Execute());
        }
        private void DeletingChildOrders(int id)
        {
            _executorCommands.DeleteEvent = DeletingHandler;
            var command = new DeleteCommand(_executorCommands, ModelsType.ChildOrders, id);

            command.Execute();
            InitChildOrders();
        }
        private void DeletingPersonnelVacation(int id)
        {
            _executorCommands.DeleteEvent = DeletingHandler;
            var command = new DeleteCommand(_executorCommands, ModelsType.PersonnelVacation, id);

            command.Execute();
            InitPersonnelVacations();
        }
        public static int Delete <T>(this DbConnection connection, string tableName, IFilter filterCondition, IEnumerable <T> items = null) where T : new()
        {
            var query = new DeleteCommand <T>(connection, tableName);

            query.Filter = filterCondition;

            return(query.Execute(items));
        }
        private void DeletingMainRequest(int id)
        {
            _executorCommands.DeleteEvent = DeletingHandler;
            var command = new DeleteCommand(_executorCommands, ModelsType.MainRequest, id);

            command.Execute();
            InitMainRequests();
        }
Exemple #18
0
        /// <summary>
        /// Delete selected items
        /// </summary>
        /// <returns>
        /// true if at least one object is deleted
        /// </returns>
        public bool DeleteSelection()
        {
            var cmd = new DeleteCommand(_graphicsList);

            cmd.Execute();
            _undoRedo.AddCommand(cmd);
            return(true);
        }
        private void DeletingMainCompetition(int id)
        {
            _executorCommands.DeleteEvent = DeletingHandler;
            var command = new DeleteCommand(_executorCommands, ModelsType.MainCompetition, id);

            command.Execute();
            InitMainComp();
        }
Exemple #20
0
        public void Throw_When_No_Canvas_Exist()
        {
            var command = new DeleteCommand();

            command.Input = new string[] { "1", "1" };
            Action test = () => command.Execute(null);

            test.Should().Throw <ArgumentNullException>();
        }
        public void Execute_ShouldThrowArgumentException_WhenInvalidTypeIspassedForDeletion(string model)
        {
            var deleteCommand = new DeleteCommand(bookServiceMock.Object, movieServiceMock.Object, starServiceMock.Object, studioServiceMock.Object);
            var name          = "test";

            Assert.Throws <ArgumentException>(() => deleteCommand.Execute(new List <string>()
            {
                model, name
            }), $"{model}s cannot be deleted.");
        }
Exemple #22
0
        public void Execute_PassEmptyParameters_ReturnWordIsNotSet()
        {
            // Arrange
            var command = new DeleteCommand(VocabularyStubFactory.Stub());

            // Act
            var result = command.Execute(new string[0]);

            // Assert
            Assert.AreEqual(result, Default.WordIsNotSet);
        }
        private void OnDelete(object sender, EventArgs e)
        {
            Image image = (Image)sender;

            image.SetAnimation();

            if (DeleteCommand != null && DeleteCommand.CanExecute(ShoppingList))
            {
                DeleteCommand.Execute(ShoppingList);
            }
        }
        /// <summary>
        /// Вызывает удаление.
        /// </summary>
        public void DeleteButtonClick()
        {
            DeleteCommand.Execute(((ListWordViewModel)SelectedItem).ID);
            Locator.NavigationHelper.CurrentFrame.GoBack();

            IsAddEnabled = IsEditVisible = false;
            IsNewEnabled = true;

            CurrentQuestion = CurrentAnswer = string.Empty;
            SelectedItem    = null;
        }
        public void ShouldDeleteFile()
        {
            // Given
            Assert.IsTrue (File.Exists (FileToDelete));

            // When
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // Then
            Assert.IsFalse(File.Exists(FileToDelete));
        }
        public void ShouldRollbackFileDeletion()
        {
            // Given
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // When
            command.Rollback ();

            // Then
            Assert.IsTrue(File.Exists(FileToDelete));
        }
Exemple #27
0
        public void Throw_When_Null_Argument()
        {
            var canvas = new Canvas(new CanvasDimentions {
                Width = 100, Height = 100
            });

            var command = new DeleteCommand();

            Action test = () => command.Execute(null);

            test.Should().Throw <ArgumentNullException>();
        }
Exemple #28
0
        public void DeleteById()
        {
            const string id   = "123123";
            var          conn = new Mocks.MSolrConnection();

            conn.post = conn.post
                        .Args("/update", string.Format("<delete><id>{0}</id></delete>", id));
            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, null), null);

            cmd.Execute(conn);
            Assert.AreEqual(1, conn.post.Calls);
        }
Exemple #29
0
        public void DeleteByMultipleId()
        {
            var ids  = new[] { "123", "456" };
            var conn = new Mocks.MSolrConnection();
            var xml  = string.Format("<delete><id>{0}</id><id>{1}</id></delete>", ids[0], ids[1]);

            conn.post = conn.post.Args("/update", xml);
            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, null), null);

            cmd.Execute(conn);
            Assert.AreEqual(1, conn.post.Calls);
        }
Exemple #30
0
        public void Execute_PassOnlyWordAndVocabularyReturnsTrue_ReturnsMeansAreNotSet()
        {
            // Arrange
            var word    = "aaa";
            var command = new DeleteCommand(VocabularyStubFactory.Stub());

            // Act
            var result = command.Execute(new [] { word });

            // Assert
            Assert.AreEqual(result, Default.MeansAreNotSet);
        }
Exemple #31
0
        public void DeleteUserProfileTest()
        {
            var command = new DeleteCommand(GetFakeApiController(), GetFakeUserRepository(), GetFakeAuthenticationKeeper());
            Task <HttpResponseMessage> result = command.Execute();

            result.Wait();

            Assert.IsFalse(result.IsFaulted);
            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Result.StatusCode, HttpStatusCode.OK);
        }
Exemple #32
0
        public void DeleteByMultipleId()
        {
            var ids   = new[] { "123", "456" };
            var mocks = new MockRepository();
            var conn  = mocks.StrictMock <ISolrConnection>();

            With.Mocks(mocks).Expecting(delegate {
                Expect.Call(conn.Post("/update", string.Format("<delete><id>{0}</id><id>{1}</id></delete>", ids[0], ids[1]))).Repeat.Once().Return("");
            }).Verify(delegate {
                var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, null));
                cmd.Execute(conn);
            });
        }
        public void ShouldReturnFileContent()
        {
            // Given
            File.WriteAllText (FileToDelete, "Hello World!");
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // When
            command.Rollback ();

            // Then
            Assert.AreEqual ("Hello World!", File.ReadAllText (FileToDelete));
        }
Exemple #34
0
        public void DeleteEntity_ShouldDeleteEntity()
        {
            // arrange
            var eventUid = Guid.NewGuid();
            var ev = new D2DEvent {Uid = eventUid};
            var stub = new FakeRepository(new Dictionary<Type, IEnumerable<IEntity>>
            {
                {typeof (D2DEvent), new[] {ev}}
            });
            var deleteCommand = new DeleteCommand<D2DEvent> {Uid = eventUid};

            // act
            deleteCommand.Execute(stub);

            // assert
            Assert.AreEqual(1, stub.RemoveCalls.Count());
            Assert.AreEqual(eventUid, stub.RemoveCalls.Single().Uid);
        }
        public void When_deleting_item_in_cache_with_time_will_block_replace_operations()
        {
            Cache["foo2"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };
            stream = GetStreamWithData(buffer);
            var replaceCommand = new ReplaceCommand();
            replaceCommand.SetContext(stream);
            replaceCommand.Init("foo2", "1", "6000", "4");

            replaceCommand.FinishedExecuting += () => wait.Set();
            replaceCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_STORED\r\n", ReadAll(6, stream));
        }
Exemple #36
0
 protected virtual void OnDeleteActivated(object sender, System.EventArgs e)
 {
     ICommand command = new DeleteCommand ("Delete command", this);
     if (command.IsExecutable == true) {
         command.Execute ();
     } else {
         MessageDialog dialog = new MessageDialog (this, DialogFlags.DestroyWithParent,
             MessageType.Error, ButtonsType.Close, "Select figures to delete.");
         dialog.Run ();
         dialog.Destroy ();
     }
 }
 public void ShouldThrowExceptionIfFileDoesntExist()
 {
     // When
     var command = new DeleteCommand (@"c:\temp\abc.txt");
     command.Execute ();
 }
        public void DeleteUserProfileTest()
        {
            var command = new DeleteCommand(GetFakeApiController(), GetFakeUserRepository(), GetFakeAuthenticationKeeper());
            Task<HttpResponseMessage> result = command.Execute();
            result.Wait();

            Assert.IsFalse(result.IsFaulted);
            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Result.StatusCode, HttpStatusCode.OK);
        }
        public void When_deleting_item_in_cache_with_time_when_item_do_not_exists_should_not_block_add_operations()
        {
            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_FOUND\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };
            stream = GetStreamWithData(buffer);
            var addCommand = new AddCommand();
            addCommand.SetContext(stream);
            addCommand.Init("foo2", "1", "6000", "4");

            addCommand.FinishedExecuting += () => wait.Set();
            addCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("STORED\r\n", ReadAll(6, stream));
        }
        public void When_deleting_item_not_in_cache_will_return_nothing_with_no_reply()
        {
            Cache["foo"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "0", "noreply");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("", ReadAll(stream));
        }
        public void When_deleting_item_in_cache_will_remove_from_cache()
        {
            Cache["foo"] = new CachedItem();

            var command = new DeleteCommand();
            command.SetContext(new MemoryStream());
            command.Init("foo");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            var cachedItem = (CachedItem)Cache.Get("foo");
            Assert.IsNull(cachedItem);
        }
        public void When_deleting_item_in_cache_will_return_deleted()
        {
            Cache["foo"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));
        }