예제 #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));
        }