コード例 #1
0
        public void CancelCommandClosesDialog()
        {
            // Arrange
            var vm = new DatabasePathViewModel();
            bool received = false;

            vm.CloseRequested += ( s, e ) => received = true;

            // Act
            vm.CancelCommand.Execute( null );

            // Assert
            Assert.IsTrue( received );
        }
コード例 #2
0
        public void BrowseFolderCommandExecutesServices()
        {
            // Arrange
            var viewServiceMock = new Mock<IViewServiceRepository>();
            viewServiceMock.Setup( x => x.Execute<IBrowseFileService, string>( It.IsAny<object>() ) ).Returns( () => Task.FromResult( "123" ) );

            var vm = new DatabasePathViewModel( viewServiceMock.Object );

            // Act
            vm.BrowseFolderCommand.Execute( null );

            // Assert
            viewServiceMock.VerifyAll();
            Assert.AreEqual( "123", vm.Path );
        }
コード例 #3
0
        public void OkCommandsNeedsPath()
        {
            // Arrange
            var vm = new DatabasePathViewModel();

            // Act
            vm.Path = string.Empty;
            bool empty = vm.OkCommand.CanExecute( null );

            vm.Path = "test";
            bool nonEmpty = vm.OkCommand.CanExecute( null );

            // Assert
            Assert.IsFalse( empty );
            Assert.IsTrue( nonEmpty );
        }