public void ConvertHexToUInteger16()
        {
            var data = "FE DCBA";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = hexInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("56506 254", result);
        }
        public void ConvertHexToBinary()
        {
            var data = "FE DCBA";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = hexInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("111111101101110010111010", result);
        }
Esempio n. 3
0
        private void Update()
        {
            var text = StringUtils.EscapeSpaces(intputText.Text);

            if (string.IsNullOrEmpty(text))
            {
                SetOutputsMessage("0");
                ClearInputs();
                return;
            }

            IInput input = inputs.FirstOrDefault(i => i.Name == inputItems.FirstOrDefault(ii => ii.IsChecked).Name);

            if (input == null)
            {
                input = inputs.FirstOrDefault(i => i.IsApplicable(text));
                var activeItem = inputItems.FirstOrDefault(i => i.Name == input.Name);
                UpdateInputs(activeItem);
            }
            else
            {
                UpdateInputs();
            }

            if (input == null || !input.IsApplicable(text))
            {
                SetOutputsMessage("Not applicable");
                return;
            }

            byte[] bytes;
            if (input.GetType() == typeof(ASCIIInput))
            {
                bytes = input.GetBytes(intputText.Text);
            }
            else
            {
                bytes = input.GetBytes(text);
            }

            if (!bytes.Any())
            {
                SetOutputsMessage("0");
                return;
            }

            outputItemsControl.ItemsSource = outputs.Select(o => new OutputItem()
            {
                Name = o.Name, Value = o.GetOutput(bytes)
            }).ToList();
        }
        public void ConvertDecToBinary()
        {
            var data = "997 997";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = decInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("11110011101001101101", result);
        }
        public void ConvertDecToUInteger16()
        {
            var data = "997 997";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = decInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("14957 15", result);
        }
        public void ConvertBinaryToUInteger16()
        {
            var data = "1111 0010 1010 1011 1010 1110 0100 0011";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = binInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("44611 62123", result);
        }
        public void ConvertBinaryToBinary()
        {
            var data = "41 1F 85 1F";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = hexInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("9.97", result);
        }
        public void ConvertBinaryToByte()
        {
            var data = "1111 0010 1010 1011 1010 1110 0100 0011";

            data = StringUtils.EscapeSpaces(data);
            var bytes  = binInput.GetBytes(data);
            var result = output.GetOutput(bytes);

            Assert.AreEqual("67 174 171 242", result);
        }
Esempio n. 9
0
        public void ConvertBinary()
        {
            var data = "1010 1010 0011 0101";

            data = StringUtils.EscapeSpaces(data);
            var actualResult   = input.GetBytes(data);
            var expectedResult = new byte[]
            {
                (byte)53,
                (byte)170,
            };

            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
Esempio n. 10
0
        public void ConvertHexadecimal()
        {
            var data = "ABCD";

            data = StringUtils.EscapeSpaces(data);
            var actualResult   = input.GetBytes(data);
            var expectedResult = new byte[]
            {
                (byte)205,
                (byte)171,
            };

            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
Esempio n. 11
0
        public void ConvertDecimal()
        {
            var data = "61491";

            data = StringUtils.EscapeSpaces(data);
            var actualResult   = input.GetBytes(data);
            var expectedResult = new byte[]
            {
                (byte)51,
                (byte)240,
            };

            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
Esempio n. 12
0
        public void ConvertASCII()
        {
            var data = "Hello";

            data = StringUtils.EscapeSpaces(data);
            var actualResult   = input.GetBytes(data);
            var expectedResult = new byte[]
            {
                (byte)72,
                (byte)101,
                (byte)108,
                (byte)108,
                (byte)111,
            };

            CollectionAssert.AreEqual(expectedResult, actualResult);
        }