示例#1
0
        public void CellIsEmpty_ReturnsDefaultValue()
        {
            //SETUP
            var sut = new CellDataParser();

            //TEST
            var result = sut.Parse(typeof(string), string.Empty);

            //VALIDATE
            Assert.That(result, Is.EqualTo(string.Empty));
        }
示例#2
0
        public void CellIsNull_ReturnsDefaultValue()
        {
            //SETUP
            var sut = new CellDataParser();

            //TEST
            var result = sut.Parse(typeof(int), null);

            //VALIDATE
            Assert.That(result, Is.EqualTo(default(int)));
        }
示例#3
0
        public void InstancePropertyTypeIsNull_ThrowsArgumentNullException()
        {
            //SETUP
            var sut = new CellDataParser();

            //TEST
            void TestDelegate() => sut.Parse(null, string.Empty);

            //VALIDATE
            Assert.Throws <ArgumentNullException>(TestDelegate);
        }
示例#4
0
        public void TypeIsNotSupport_ThrowsInvalidOperationException()
        {
            //SETUP
            var cellData = _fixture.Create <string>();
            var sut      = new CellDataParser();

            //TEST
            void TestDelegate() => sut.Parse(typeof(UnitTestItem), cellData);

            //VALIDATE
            Assert.Throws <InvalidOperationException>(TestDelegate);
        }
示例#5
0
        public void CellHasValidData_ReturnsValueAsString()
        {
            //SETUP
            var cellValue         = _fixture.Create <string>();
            var cellValueAsString = cellValue.ToString();
            var sut = new CellDataParser();

            //TEST
            var result = sut.Parse(typeof(string), cellValueAsString);

            //VALIDATE
            Assert.That(result, Is.EqualTo(cellValue));
        }
示例#6
0
        public void CellHasInvalidData_ThrowsInvalidOperationException()
        {
            //SETUP
            var cellValueAsString = _fixture.Create <string>();
            var sut = new CellDataParser();

            //TEST
            void TestDelegate() => sut.Parse(typeof(int), cellValueAsString);

            //VALIDATE
            var ex = Assert.Throws <InvalidOperationException>(TestDelegate);

            Assert.That(ex.Message, Is.EqualTo($"Could not parse value '{cellValueAsString}' to {typeof(int).Name}"));
        }