Пример #1
0
        protected virtual ContainerBuilder Register()
        {
            var builder = new ContainerBuilder();

            builder.Register(c =>
                             ViewModelNavigation.Create(MvvmContainerAutofac.Create(c.Resolve <IComponentContext>()), true))
            .SingleInstance();
            builder.RegisterType <HomeViewModel>();
            builder.RegisterType <SecondViewModel>();
            builder.RegisterType <ThirdViewModel>();
            builder.RegisterType <HomeView>()
            .AsView();
            builder.RegisterType <SecondView>()
            .AsView();
            return(builder);
        }
        public async Task ResolveNamedWithArgs()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <FakeWithArgsViewModel>();

            builder.RegisterType <FakeWithArgsView>()
            .AsView();

            builder.Register(c => ViewModelNavigation.Create(MvvmContainerAutofac.Create(c.Resolve <IComponentContext>() as LifetimeScope)));

            var container = builder.Build();

            var navigationMock = new Mock <INavigation>();

            await container.Resolve <IViewModelNavigator>()
            .Navigate <FakeWithArgsViewModel>(navigationMock.Object,
                                              new NamedParameter("name", "pippo"));

            navigationMock.Verify(m => m.PushAsync(It.IsAny <FakeWithArgsView>()), Times.Once);
        }