示例#1
0
        public void ToolBarCommandsDelegation()
        {
            var lazyShellViewModel = new Lazy <IShellViewModel>(() => new MockShellViewModel());
            var shellService       = new ShellService(lazyShellViewModel);

            var mockShellViewModel = (MockShellViewModel)lazyShellViewModel.Value;
            var emptyCommand       = new DelegateCommand(() => { });
            var newToolBarCommands = new ToolBarCommand[]
            {
                new ToolBarCommand(emptyCommand, "Command 1"),
                new ToolBarCommand(emptyCommand, "Command 2")
            };

            Assert.IsFalse(mockShellViewModel.ToolBarCommands.Any());
            shellService.AddToolBarCommands(newToolBarCommands);
            Assert.IsTrue(mockShellViewModel.ToolBarCommands.SequenceEqual(newToolBarCommands));
            shellService.ClearToolBarCommands();
            Assert.IsFalse(mockShellViewModel.ToolBarCommands.Any());
        }