Esempio n. 1
0
        public void InitializePage_12Hours_CheckUpdateTimeValue()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };
            var guid = new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753");
            var time = DateTime.Today; // start today at 0:00

            while (time.Date == DateTime.Today)
            {
                // arrange
                var request = new TimePickerFullModeRequest("Header", time, guid);
                vm.InitializePage(request);

                // act
                vm.UpdateTimeValue();

                // assert
                Assert.AreEqual(time, vm.Value, "The time cound not set correctly");

                // Add 1 Minute
                time = time.AddMinutes(1);
            }
        }
Esempio n. 2
0
        public void InitializePage_12Hours_CheckInitialization()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };
            var guid = new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753");
            var time = DateTime.Today; // start today at 0:00

            while (time.Date == DateTime.Today)
            {
                // act
                var request = new TimePickerFullModeRequest("Header", time, guid);
                vm.InitializePage(request);

                // assert
                int awaitedHour = (time.Hour % 12);
                if (awaitedHour == 0)
                {
                    awaitedHour = 12;
                }

                Assert.AreEqual(awaitedHour, vm.SelectedHour.Hour, "The hour did not match");
                Assert.AreEqual(time.Minute, vm.SelectedMinute.Minute, "The minute did not match");

                // Add 1 Minute
                time = time.AddMinutes(1);
            }
        }
Esempio n. 3
0
        public void InitializePage_UndefinedData_ReturnInstantly()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel();

            // act & assert (it's not allowed that any exception will be thrown)
            vm.InitializePage("Some invalid data");
        }
Esempio n. 4
0
        public void Initialize_CommandBinding_ValidateBinding()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel();

            // act
            vm.Initialize();

            // assert
            Assert.IsNotNull(vm.CheckCommand, "The check command must be bound");
            Assert.IsNotNull(vm.CancelCommand, "The cancel command must be bound");
        }
Esempio n. 5
0
        public void TimePickerFullModeViewModel_Constructor_Validate12Hours()
        {
            // arrange & act
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };

            // assert
            Assert.AreEqual(2, vm.AllDesignators.Length, "We expected two designators AM/PM");
            Assert.AreEqual(24, vm.AllHours.Length, "We expected 24 hours");
            Assert.AreEqual(60, vm.AllMinutes.Length, "We expected 60 minutes");
        }
Esempio n. 6
0
        public void SelectedDesignator_Change_CheckResultingValue()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };
            var request = new TimePickerFullModeRequest("Header", DateTime.Today.AddHours(3), new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753"));

            vm.InitializePage(request);

            // act
            vm.SelectedDesignator = vm.AllDesignators[1];

            // assert
            Assert.AreEqual(15, vm.Value.Hour, "The resulting value must switch from 3 to 15 o´clock");
        }
Esempio n. 7
0
        public void SelectedMinute_Change_CheckResultingValue()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };
            var request = new TimePickerFullModeRequest("Header", DateTime.Today.AddMinutes(12), new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753"));

            vm.InitializePage(request);

            // act
            vm.SelectedMinute = vm.AllMinutes[46];

            // assert
            Assert.AreEqual(46, vm.Value.Minute, "Hours are set manually to 15 o´clock. so we expect to see the same");
        }
Esempio n. 8
0
        public void IsDesignatorVisible_SetFalse_CheckHours()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = true
            };
            var request = new TimePickerFullModeRequest("Header", DateTime.Today.AddHours(15), new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753"));

            // act
            vm.IsDesignatorVisible = false;
            vm.InitializePage(request);

            // assert
            Assert.AreEqual(15, vm.SelectedHour.Hour, "15:00 o'clock means 3 pm");
            Assert.AreEqual(1, vm.SelectedDesignator.DesignatorNumber, "Second designator");
        }
Esempio n. 9
0
        public void InitializePage_TimePickerFullModeRequest_DataHasBeenSet()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel {
                IsDesignatorVisible = false
            };
            var guid    = new Guid("B43E7314-988E-41A8-B4E4-A02BA93FC753");
            var request = new TimePickerFullModeRequest("Header", new DateTime(2012, 10, 23, 15, 23, 22), guid);

            // act
            vm.InitializePage(request);

            // assert
            Assert.AreEqual("Header", request.FullModeHeader, "The header is not set as expected");
            Assert.AreEqual(vm.TimePickerId, guid, "The TimePicker id is not as requested");
            Assert.AreEqual(23, vm.SelectedMinute.Minute, "The minute has not been set as expected");
            Assert.AreEqual(15, vm.SelectedHour.Hour, "The hour has not been set as expected");
        }
Esempio n. 10
0
        public void CancelCommand_Execute_GoBackNavigationRequestHasBeenFired()
        {
            // arrange
            var vm = new TimePickerFullModeViewModel();

            vm.Initialize();
            vm.InitializePage(new TimePickerFullModeRequest("Header", DateTime.Today.AddHours(3), checkCommandId));

            Kernel.Instance.EventAggregator.Subscribe(this);
            try
            {
                // Execute command and send the event
                vm.CancelCommand.Execute(null);

                // Wait 100ms for event
                cancelCommandEvent.WaitOne(100);
            }
            finally
            {
                Kernel.Instance.EventAggregator.Unsubscribe(this);
            }
        }