Forum Xamarin.Forms

Unittesting MVVMcross navigation

Im using MvvmCross for viewmodal navigation

I want to verify Xamarin command navigation from unit test.

How can I verify the navigation

This is my implimented code so far

public class UnitTestViewModelTest : MvxIoCSupportingTest
    {
        private readonly Mock<IMvxNavigationService> _mocMvxNavigationService;       
        private readonly UnitTestingViewModel _unitTestingViewModel;
        public UnitTestViewModelTest()
        {
            _mocMvxNavigationService = new Mock<IMvxNavigationService>();
            _unitTestingViewModel = new UnitTestingViewModel(_mocMvxNavigationService.Object);
        }

        [Fact]
        public void NavigateVerify()
        {
            _unitTestingViewModel.NavigateToNextpageCommand.ExecuteAsync(null); 
        }
    }

I have tried with navigation verify it gives me an compilation error

_mocMvxNavigationService.Verify(s => s.Navigate<NavigateToNextpageViewModel>(), Times.Once());

Sign In or Register to comment.