public void CreateNumericEntryCellViewModelValidateUnsignedInteger()
        {
            var cell = new NumericEntryCellViewModel();

            cell.MaximumValue = 20;
            cell.Value        = 23;
            Assert.IsFalse(cell.IsValid);
        }
        public void CreateNumericEntryCellViewModelSettingTextSetsNumber()
        {
            var cell = new NumericEntryCellViewModel()
            {
                Text = "23"
            };

            Assert.AreEqual(23M, cell.Value);
        }
        public void CreateNumericEntryCellViewModelSettingTextInvalidLeavesValueNullAndInvalid()
        {
            var cell = new NumericEntryCellViewModel()
            {
                Text = "ballbags"
            };

            Assert.IsNull(cell.Value);
            Assert.IsFalse(cell.IsValid);
        }
        public void CreateNumericEntryCellViewModelExpectSuccess()
        {
            var cell = new NumericEntryCellViewModel();

            Assert.AreEqual(cell.Accessories, CellIndicators.None);
            Assert.IsNull(cell.Text);
            Assert.IsNull(cell.MaximumValue);
            Assert.IsNull(cell.MinimumValue);
            Assert.IsFalse(cell.AllowCellSelection);
            Assert.IsTrue(cell.IsEnabled);
            Assert.IsNull(cell.CommandParameter);
            Assert.AreEqual(cell.ClearButtonMode, TextClearButtonMode.WhilstEditing);
            Assert.IsTrue(cell.IsValid);
            Assert.IsFalse(cell.IsSigned);
        }
예제 #5
0
        public WeightConversionTableViewModel(IActionSheetController sheetController, INavigationService navigationService, ISchedulerService scheduler, IViewModelFactory viewModelFactory)
            : base(navigationService, scheduler)
        {
            if (viewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(viewModelFactory));
            }

            Title             = "Weight Conversion";
            ShowNavigationBar = true;
            Intent            = TableIntent.Form;

            SeparatorStyle = TableCellSeparatorStyle.SingleLine;
            _topSection    = AddSection("Converter");

            var poundsCell = new NumericEntryCellViewModel()
            {
                Label = "Pounds", IsInteger = false
            };
            var kilosCell = new NumericEntryCellViewModel()
            {
                Label = "Kilos", IsInteger = false
            };


            poundsCell.Values.ObserveOn(Scheduler.UiScheduler)
            .Where(e => e.HasValue)
            .Subscribe((e) =>
            {
                // We have a new pounds value, we need to process this and push the related kilos value to the kilos cell.
                kilosCell.Value = WeightConverter.ToKilosFromPounds(e.Value);
            });

            _topSection.AddCell(poundsCell);


            kilosCell.Values.ObserveOn(Scheduler.UiScheduler)
            .Where(e => e.HasValue)
            .Subscribe((e) =>
            {
                poundsCell.Value = ImperialWeight.FromKilos(e.Value).TotalPounds;
            });

            _topSection.AddCell(kilosCell);
        }