示例#1
0
        public void RunTests()
        {
            double parsed;

            // Acceptable value formats that should return true:
            Assert.IsTrue(CSVConsolidator.TryParseValue("", out parsed));
            Assert.AreEqual(parsed, 0.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("0", out parsed));
            Assert.AreEqual(parsed, 0.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("1", out parsed));
            Assert.AreEqual(parsed, 1.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("10", out parsed));
            Assert.AreEqual(parsed, 10.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("100", out parsed));
            Assert.AreEqual(parsed, 100.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("1000", out parsed));
            Assert.AreEqual(parsed, 1000.0);
            Assert.IsTrue(CSVConsolidator.TryParseValue("1,000", out parsed));
            Assert.AreEqual(parsed, 1000.0);

            // Unacceptable value formats that should return false:
            Assert.IsFalse(CSVConsolidator.TryParseValue("1,ooo", out parsed));
            Assert.IsFalse(CSVConsolidator.TryParseValue("1,2,99", out parsed));
            Assert.IsFalse(CSVConsolidator.TryParseValue("4,49,1", out parsed));
            Assert.IsFalse(CSVConsolidator.TryParseValue("28.01.29", out parsed));
            Assert.IsFalse(CSVConsolidator.TryParseValue(".14.01", out parsed));
        }
        public void RunTests()
        {
            char slash = Path.DirectorySeparatorChar;

            // Retrieve the test csv content.
            string[] mockOffice1 = File.ReadAllLines(
                $"InputSets{slash}InputCSVs{slash}mock_office_1.csv");
            string[] mockOffice2 = File.ReadAllLines(
                $"InputSets{slash}InputCSVs{slash}mock_office_2.csv");
            string mockOutput1 = File.ReadAllText(
                $"InputSets{slash}expected_output.csv");

            string output = CSVConsolidator.Consolidate(
                new string[][] { mockOffice1, mockOffice2 });

            // Check to see if the consolidator came up with
            // what we expected it to.
            Assert.AreEqual(mockOutput1, output);
        }