This project has moved. For the latest updates, please go here.

Is there a drawback to defininge the strings as constants in the unit tests?

Apr 12, 2012 at 6:40 PM
Edited Apr 12, 2012 at 7:39 PM

Like this:

 

    public abstract class MatrixLoader
    {
        protected const string Singular3X3 = "Singular3X3";
        protected const string Square3X3 = "Square3x3";
        protected const string Square4X4 = "Square4x4";
        protected const string Singular4X4 = "Singular4x4";
        protected const string Tall3X2 = "Tall3x2";
        protected const string Wide2X3 = "Wide2x3";

 

Then the strings can be referenced as fields, the tests seems to run fine.

The tests can be written like this then (withe intellisense)

        [TestCase(Square3x3)]
        [TestCase(Square4x4)]
        [TestCase(Tall3x2)]
        [TestCase(Wide2x3)]
        public void CanEquateMatrices(string name)
        {
            var matrix1 = CreateMatrix(TestData2D[name]);