Ejemplo n.º 1
0
        public void ExtractArgs_NullOrEmptyString_ReturnsEmptyList()
        {
            var resultNullString  = CliUtils.ExtractAndParseDoubleParams(null);
            var resultEmptyString = CliUtils.ExtractAndParseDoubleParams("");

            Assert.That(resultNullString, Is.EqualTo(new List <object>()));
            Assert.That(resultEmptyString, Is.EqualTo(new List <object>()));
        }
Ejemplo n.º 2
0
        public void ExtractParams_CorrectlyFormattedString_ReturnsExpectedList()
        {
            const string inputString = "2.1, 1.0, 0.1,1 ";
            var          result      = CliUtils.ExtractAndParseDoubleParams(inputString);

            double[] expected = { 2.1, 1.0, 0.1, 1.0 };

            if (result.Length == expected.Length)
            {
                for (int i = 0; i < expected.Length; i++)
                {
                    Assert.That(result[i], Is.EqualTo(expected[i]));
                }
            }
            else
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 3
0
        public void ExtractParams_StringWithExtraComma_ReturnsListWithEmptyStrings()
        {
            const string inputString = ",2.1, 1.0, 0.1,1, ";
            var          result      = CliUtils.ExtractAndParseDoubleParams(inputString);

            double[] expected = { 0, 2.1, 1.0, 0.1, 1, 0 };

            if (result.Length == expected.Length)
            {
                for (int i = 0; i < expected.Length; i++)
                {
                    Assert.That(result[i], Is.EqualTo(expected[i]));
                }
            }
            else
            {
                Assert.Fail();
            }
        }