Ejemplo n.º 1
0
        public void TemplateVM_SelectionReplaceDifferentList_DoReplace()
        {
            int    count    = 0;
            string propName = "";
            var    model    = new DummyTeam {
                Name = "dash",
            };

            model.List.Add(new Utils.PlayerDummy());
            model.List.Add(new Utils.PlayerDummy());
            model.List.Add(new Utils.PlayerDummy());

            var viewModel = new DummyTeamVM {
                Model = model
            };

            viewModel.Select(viewModel.ViewModels.First());
            viewModel.PropertyChanged += (sender, e) => { count++; propName = e.PropertyName; };

            viewModel.Selection.Replace(viewModel.ViewModels);

            Assert.AreEqual(1, count);
            Assert.AreEqual("Collection_Selection", propName);
            Assert.AreSame(viewModel.Selection [0], viewModel.ViewModels[0]);
            Assert.AreSame(viewModel.Selection [1], viewModel.ViewModels[1]);
            Assert.AreSame(viewModel.Selection [2], viewModel.ViewModels [2]);
        }
Ejemplo n.º 2
0
        public void TestSelect()
        {
            var model = new DummyTeam {
                Name = "dash",
            };
            var player = new Utils.PlayerDummy();

            model.List.Add(player);
            var viewModel = new DummyTeamVM {
                Model = model
            };

            viewModel.Select(viewModel.ViewModels.First());

            Assert.AreEqual(1, viewModel.Selection.Count);
            Assert.AreEqual(player, viewModel.Selection.First().Model);
        }
Ejemplo n.º 3
0
        public void Selection_CollectionCleared_SelectionSynced()
        {
            var model = new DummyTeam {
                Name = "dash",
            };

            model.List.Add(new Utils.PlayerDummy());
            model.List.Add(new Utils.PlayerDummy());
            var viewModel = new DummyTeamVM {
                Model = model
            };

            var element = viewModel.ViewModels [0];

            viewModel.Select(element);
            viewModel.ViewModels.Clear();

            Assert.IsEmpty(viewModel.Selection);
        }