Exemplo n.º 1
0
        public void Construction()
        {
            // arrange

            // act
            var converter = new NumberConverterViewModel();

            // assert
            Assert.NotNull(converter);
            Assert.Null(converter.EntryValue);
            Assert.Equal(NumberSystem.Binary, converter.EntryNumberSystem);
            Assert.Null(converter.ResultValue);
            Assert.Equal(NumberSystem.Decimal, converter.ResultNumberSystem);
            Assert.Null(converter.ErrorMessage);
            Assert.False(converter.HasError);
        }
Exemplo n.º 2
0
        public void Convert_WithValidFormatError(
            string initialEntry,
            NumberSystem initialEntrySystem)
        {
            // arrange
            var converter = new NumberConverterViewModel
            {
                EntryValue        = initialEntry,
                EntryNumberSystem = initialEntrySystem,
            };

            // act
            converter.Convert();

            // assert
            Assert.Null(converter.ResultValue);
            Assert.Contains(initialEntrySystem.ToString(), converter.ErrorMessage);
            Assert.True(converter.HasError);
        }
Exemplo n.º 3
0
        public void Convert_Clicked()
        {
            // arrange
            using var ctx = new TestContext();
            var vm = new NumberConverterViewModel
            {
                EntryValue        = "13",
                EntryNumberSystem = NumberSystem.Octal
            };

            ctx.Services.AddSingleton <NumberConverterViewModel>(vm);

            var cut = ctx.RenderComponent <NumberConverter>();

            // act
            cut.Find("#btn-convert").Click();

            // assert
            cut.MarkupMatches(NumberConverterExpectedResults.ConvertToDecimalResult);
        }
Exemplo n.º 4
0
        public void Convert_WithValidEntryValue(
            string initialEntry,
            NumberSystem initialEntrySystem,
            NumberSystem initialResultSystem,
            string expectedDecimal)
        {
            // arrange
            var converter = new NumberConverterViewModel
            {
                EntryValue         = initialEntry,
                EntryNumberSystem  = initialEntrySystem,
                ResultNumberSystem = initialResultSystem
            };

            // act
            converter.Convert();

            // assert
            Assert.Equal(expectedDecimal, converter.ResultValue);
            Assert.Null(converter.ErrorMessage);
            Assert.False(converter.HasError);
        }
 public NumberConverterView()
 {
     InitializeComponent();
     DataContext = new NumberConverterViewModel();
 }