Пример #1
0
        public void ReadingIs5DigitsExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsTrue(validator.TryParseMeterReading("12345", out string meterReading));
            Assert.AreEqual("12345", meterReading);
        }
Пример #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);
        }
Пример #3
0
        public void AccountIdIsPositiveIntegerExpectSuccess()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsTrue(validator.TryParseAccountId("78", out int accountId));
            Assert.AreEqual(78, accountId);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #7
0
        public void MeterReadingIsInvalidDateTimeExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReadingDateTime("31/04/2019 09:24", out DateTime meterReadingDateTime));
        }
Пример #8
0
        public void AccountIdIsNotANumberExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("ABC", out int accountId));
        }
Пример #9
0
        public void AccountIdIsDecimalExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("78.45", out int accountId));
        }
Пример #10
0
        public void AccountIdIsNegativeIntegerExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseAccountId("-78", out int accountId));
        }
Пример #11
0
        public void ReadingIsNotANumberExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("12X45", out string meterReading));
        }
Пример #12
0
        public void ReadingIsMissingExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("", out string meterReading));
        }
Пример #13
0
        public void ReadingIsNegativeExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

            Assert.IsFalse(validator.TryParseMeterReading("-12345", out string meterReading));
        }
Пример #14
0
        public void ReadingIs6DigitsExpectFailure()
        {
            MeterCsvValidator validator = new MeterCsvValidator();

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