コード例 #1
0
        public void WhenModelIsSet_IsValidIsUpdated()
        {
            var vm = new ScheduleViewModel();
            var model = new ScheduleEditMock();
            var propertiesChanged = new List<string>();

            model.MakeValid();

            vm.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName);
            
            // Act.
            vm.Model = model;

            Assert.IsTrue(vm.IsValid);
            Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid"));

            model = new ScheduleEditMock();
            model.MakeInvalid();

            propertiesChanged.Clear();

            // Act.
            vm.Model = model;

            Assert.IsFalse(vm.IsValid);
            Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid"));
        }
コード例 #2
0
        public void PropertiesTest()
        {
            TestsHelper.TestPublicPropertiesGetSet(new ScheduleViewModel());

            // Test StartImmediately property. 
            var vm = new ScheduleViewModel();

            var model = new ScheduleEditMock();

            vm.Model = model;

            vm.StartImmediately = true;
            Assert.IsNull(model.StartOn);

            vm.StartImmediately = false;
            Assert.IsNotNull(model.StartOn);

            vm.StartImmediately = true;
            Assert.IsNull(model.StartOn);

            // Test NoEndDate property.

            vm.Model = model;

            vm.NoEndDate = true;
            Assert.IsNull(model.EndOn);

            vm.NoEndDate = false;
            Assert.IsNotNull(model.EndOn);

            vm.NoEndDate = true;
            Assert.IsNull(model.EndOn);
        }
コード例 #3
0
        public void OnSaved_Test()
        {
            var vm = new ScheduleViewModel();
            var model = new ScheduleEditMock();

            vm.Initialize(model);
            
            model = new ScheduleEditMock();

            vm.OnSaved(model);

            Assert.AreSame(model, vm.Model);
        }
コード例 #4
0
        public void Initialize_Test()
        {
            var vm = new ScheduleViewModel();

            Assert.IsNull(vm.Model);

            var model = new ScheduleEditMock();

            vm.Initialize(model);

            Assert.AreSame(model, vm.Model);
        }