示例#1
0
        public async Task UpdateNavigatesToContent()
        {

            var content = new Mock<IContentViewModel>();
            var viewmodel = new MainViewModel(user);

            await viewmodel.Update(content.Object);

            content.Verify(c => c.OnNavigate());
        }
示例#2
0
        public async Task UpdateClosesOldContent()
        {
            var old = new Mock<IContentViewModel>();
            var current = new Mock<IContentViewModel>();

            var viewmodel = new MainViewModel(user);

            await viewmodel.Update(old.Object);
            await viewmodel.Update(current.Object);

            old.Verify(o => o.OnClose());
        }
示例#3
0
        public async Task UpdateRaisesChangeEvent()
        {
            var content = new Mock<IContentViewModel>();
            var viewmodel = new MainViewModel(user);

            bool called = false;
            viewmodel.PropertyChanged += (sender, args) =>
            {
                called = true;
                Assert.Equal(nameof(viewmodel.Content), args.PropertyName);
            };
            await viewmodel.Update(content.Object);

            Assert.True(called);
        }
示例#4
0
        public NavigationServiceTest()
        {

            var builder = new ContainerBuilder();
            var user = new UserViewModel(new Mock<IUser>().Object);
            builder.RegisterInstance(new MainViewModel(user));

            builder.RegisterType<NavigationService>().AsSelf().As<INavigationService>();

            builder.RegisterType<DummyClass>().AsSelf().Keyed<IContentViewModel>(Keys.Value1);
            builder.RegisterType<TestClass>().AsSelf().Keyed<IContentViewModel>(Keys.Value2);

            builder.RegisterType<ContentScope>();

            container = builder.Build();

            main = container.Resolve<MainViewModel>();
        }