コード例 #1
0
        public void ChangeViewModel()
        {
            NamedViewModelMock[] namedViewModels = new NamedViewModelMock[2]
            {
                new NamedViewModelMock("0"),
                new NamedViewModelMock("1")
            };

            var applicationVm = new ApplicationViewModel(namedViewModels);

            applicationVm.ChangeViewModel(namedViewModels[1]);

            Assert.Same(namedViewModels[1], applicationVm.CurrentViewModel);
        }
コード例 #2
0
        public void ChangeViewModelOnlyIfExists()
        {
            NamedViewModelMock[] namedViewModels = new NamedViewModelMock[2]
            {
                new NamedViewModelMock("0"),
                new NamedViewModelMock("1")
            };

            var applicationVm = new ApplicationViewModel(namedViewModels);

            NamedViewModelMock badViewModel = new NamedViewModelMock("2");

            Assert.Throws <ArgumentOutOfRangeException>(
                () => { applicationVm.ChangeViewModel(badViewModel); }
                );
        }