コード例 #1
0
            public void Initialize()
            {
                this.automation = new Mock<IAutomationExtension>();
                this.status = this.automation.As<ICommandStatus>();
                this.menu = automation.As<IAutomationMenuCommand>();
                this.menu.Setup(m => m.Text).Returns("Foo");

                this.target = new AutomationMenuOptionViewModel(this.automation.Object);
            }
コード例 #2
0
            public void WhenAutomationNotImplementingStatus_ThenCanExecuteIsStillTrue()
            {
                var automation = new Mock<IAutomationExtension>();
                var menu = automation.As<IAutomationMenuCommand>();
                menu.Setup(m => m.Text).Returns("Foo");
                menu.Setup(x => x.Enabled).Returns(true);

                this.target = new AutomationMenuOptionViewModel(automation.Object);
                Assert.True(this.target.Command.CanExecute(null));
            }
コード例 #3
0
            public void WhenImageNotPresent_ThenImageIsSetAndTypeIsNone()
            {
                var automation = new Mock<IAutomationExtension>();
                var menu = automation.As<IAutomationMenuCommand>();

                menu.Setup(m => m.Text).Returns("Foo");
                menu.Setup(a => a.IconPath).Returns<string>(null);

                var viewModel = new AutomationMenuOptionViewModel(automation.Object);

                Assert.Equal(IconType.None, viewModel.IconType);
                Assert.Null(viewModel.ImagePath);
            }
コード例 #4
0
            public void WhenImagePresent_ThenImageIsSetAndTypeIsImage()
            {
                var automation = new Mock<IAutomationExtension>();
                var menu = automation.As<IAutomationMenuCommand>();

                menu.Setup(m => m.Text).Returns("Foo");
                menu.Setup(a => a.IconPath).Returns("pack://application,,,/Assembly;component/path/ico.ico");

                var viewModel = new AutomationMenuOptionViewModel(automation.Object);

                Assert.Equal(IconType.Image, viewModel.IconType);
                Assert.NotNull(viewModel.ImagePath);
            }