Ejemplo n.º 1
0
 public AppData()
 {
     var source = new ConversionItemViewModel(UnitFactory.UnitFromName(Settings.LastUnitSource, Settings.LastCategory));
     source.Value = Settings.LastUnitSourceValue;
     var destination = new ConversionItemViewModel(UnitFactory.UnitFromName(Settings.LastUnitDestination, Settings.LastCategory));
     CurrentConversion = new SimpleConvertViewModel(Settings.LastCategory,source, destination);
 }
        public void MultipleNonDecimalNumberWorks()
        {
            const string expectedValue = "22";
            var model = new SimpleConvertViewModel();

            model.DigitPressedCommand.Execute("2");
            model.DigitPressedCommand.Execute("2");

            Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
        }
        public void LeadingNegativeWorks()
        {
            const string expectedValue = "-0";
            var model = new SimpleConvertViewModel();

            model.ClearCommand.Execute(null);
            model.NegateCommand.Execute(null);

            Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
        }
        public void LeadingDoubleZerosThenAnotherNumberWorks()
        {
            const string expectedValue = "1";
            var model = new SimpleConvertViewModel();

            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute("1");

            Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
        }
        public void TypingDecimalAfterSingleZeroWorks()
        {
            const string expectedValue = "0.";
            var model = new SimpleConvertViewModel();

            model.ClearCommand.Execute(null);
            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute(".");

            Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
        }
 public void NewSimpleConvertViewModelHasZero()
 {
     const string expectedValue = "0";
     var model = new SimpleConvertViewModel();
     Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
 }
        public void TypingMultpleLeadingZeroDoesntShow()
        {
            const string expectedValue = "0";
            var model = new SimpleConvertViewModel();

            model.ClearCommand.Execute(null);
            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute("0");
            model.DigitPressedCommand.Execute("0");

            Assert.IsTrue(model.UserInputValue == expectedValue, $"Expected {expectedValue} but had value {model.UserInputValue}");
        }