public void ShouldConstructFromMilliseconds()
        {
            var viewModel = new SectorTimeViewModel(45123);

            Assert.That(viewModel.Seconds, Is.EqualTo(45));
            Assert.That(viewModel.Milliseconds, Is.EqualTo(123));
        }
        public SectorTimeInputPage()
        {
            InitializeComponent();

            InitializeLoopingLists();
            BackKeyPress += SectorTimeInputPage_BackKeyPress;

            ViewModel = new SectorTimeViewModel();
        }
        public void ShouldCalculateThirdSectorFromLapTimeAndFirstAndSecondSectors()
        {
            var lapTime = new LapTimeViewModel {Minute = 1, Seconds = 45, Milliseconds = 674 }; // 105674 milliseconds
            var firstSector = new SectorTimeViewModel {Seconds = 35, Milliseconds = 342 };  // 35342 milliseconds
            var secondSector = new SectorTimeViewModel {Seconds = 42, Milliseconds = 714 }; // 42714 milliseconds

            var viewModel = new MainViewModel {LapTime = lapTime, FirstSector = firstSector, SecondSector = secondSector};

            var thirdSector = viewModel.ThirdSector;

            // 3rd sector should be 27618 milliseconds
            Assert.That(thirdSector.Seconds, Is.EqualTo(27));
            Assert.That(thirdSector.Milliseconds, Is.EqualTo(618));
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            var queryString = NavigationContext.QueryString;
            if (queryString.ContainsKey("sector"))
            {
                Sector = int.Parse(queryString["sector"]);
                PageTitle.Text = string.Format("Enter sector {0} time", Sector);
            }

            if (queryString.ContainsKey("time"))
            {
                ViewModel = new SectorTimeViewModel(int.Parse(queryString["time"]));
                SecondList.SelectedIndex = ViewModel.Seconds;
                MillisecondList1.SelectedIndex = (ViewModel.Milliseconds/100);
                MillisecondList2.SelectedIndex = ((ViewModel.Milliseconds%100)/10);
                MillisecondList3.SelectedIndex = (ViewModel.Milliseconds%10);
            }

            base.OnNavigatedTo(e);
        }
 public MainViewModel()
 {
     LapTime = new LapTimeViewModel();
     FirstSector = new SectorTimeViewModel();
     SecondSector = new SectorTimeViewModel();
 }
        public void ShouldNotAllowSecondsLargerThanFiftyNine()
        {
            var viewModel = new SectorTimeViewModel { Seconds = 2 };

            Assert.That(() => viewModel.Seconds = 60, Throws.TypeOf<ArgumentException>().With.Message.EqualTo("Seconds must be between 0 and 59"));
        }
        public void ShouldNotAllowMinusSeconds()
        {
            var viewModel = new SectorTimeViewModel { Seconds = 0 };

            Assert.That(() => viewModel.Seconds = -1, Throws.TypeOf<ArgumentException>().With.Message.EqualTo("Seconds must be between 0 and 59"));
        }
        public void ShouldNotAllowMillesecondsLargerThanNineHundredsAndNintyNine()
        {
            var viewModel = new SectorTimeViewModel { Milliseconds = 2 };

            Assert.That(() => viewModel.Milliseconds = 1000, Throws.TypeOf<ArgumentException>().With.Message.EqualTo("Milliseconds must be between 0 and 999. Value is 1000"));
        }
        public void ShouldConvertToString()
        {
            var viewModel = new SectorTimeViewModel { Seconds = 45, Milliseconds = 555 };

            Assert.That(viewModel.ToString(), Is.EqualTo("45.555"));
        }