Esempio n. 1
0
        public void ReadingIs5DigitsExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsTrue(validator.TryParseMeterReading("12345", out string meterReading));
            Assert.AreEqual("12345", meterReading);
        }
Esempio n. 2
0
        public void MeterReadingIsValidDateTimeExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsTrue(validator.TryParseMeterReadingDateTime("20/05/2019 09:24", out DateTime meterReadingDateTime));
            Assert.AreEqual(new DateTime(2019, 05, 20, 9, 24, 0), meterReadingDateTime);
        }
Esempio n. 3
0
        public void AccountIdIsPositiveIntegerExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsTrue(validator.TryParseAccountId("78", out int accountId));
            Assert.AreEqual(78, accountId);
        }
Esempio n. 4
0
        public void OneHeaderIsMissingExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            string[] validHeaders = new string[] { "A", "B", "C" };
            string[] headerTokens = new string[] { "A", "B" };

            Assert.IsFalse(validator.ValidateHeaders(validHeaders, headerTokens));
        }
Esempio n. 5
0
        public void ExtraHeaderExistsExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            string[] validHeaders = new string[] { "A", "B", "C" };
            string[] headerTokens = new string[] { "A", "B", "C", "D" };

            Assert.IsFalse(validator.ValidateHeaders(validHeaders, headerTokens));
        }
Esempio n. 6
0
        public void All3HeadersExistExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            string[] validHeaders = new string[] { "A", "B", "C" };
            string[] headerTokens = new string[] { "C", "B", "A" };

            Assert.IsTrue(validator.ValidateHeaders(validHeaders, headerTokens));
        }
Esempio n. 7
0
        public void MeterReadingIsInvalidDateTimeExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReadingDateTime("31/04/2019 09:24", out DateTime meterReadingDateTime));
        }
Esempio n. 8
0
        public void AccountIdIsNotANumberExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("ABC", out int accountId));
        }
Esempio n. 9
0
        public void AccountIdIsDecimalExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("78.45", out int accountId));
        }
Esempio n. 10
0
        public void AccountIdIsNegativeIntegerExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("-78", out int accountId));
        }
Esempio n. 11
0
        public void ReadingIsNotANumberExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("12X45", out string meterReading));
        }
Esempio n. 12
0
        public void ReadingIsMissingExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("", out string meterReading));
        }
Esempio n. 13
0
        public void ReadingIsNegativeExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("-12345", out string meterReading));
        }
Esempio n. 14
0
        public void ReadingIs6DigitsExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("123456", out string meterReading));
        }