Requirements:
Return total count of files (records) for date. Assign a modifier (single character A-Z 0-9) to represent the count.
Info: This modifier along with the date / time will be used to trace the file through out the system.
Current Solution:
[Test]
public void FileIDModifierShouldReturn9()
{
var filecountfordate = 35;
var chararray = new[]{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R'
, 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9'
};
var expected = "9";
var actual = chararray[filecountfordate].ToString();
Assert.AreEqual(expected, actual);
}
Problem: When the file count is greater than the index of the array an exception is thrown obviously.
2nd Test:
[Test]
public void WhenFileIDModifierIsBiggerThanArrayArrayShouldStartOverAndReturnValue()
{
var filecountfordate = 71;
var chararray = new[]{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R'
, 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9'
};
if (filecountfordate > 35)
{
filecountfordate = filecountfordate%36;
}
var expected = "9";
var actual = chararray[filecountfordate].ToString();
Assert.AreEqual(expected, actual);
}
My problem is I need to be able to restart at the beginning of the array pragmatically, with out having endless "if" statements. Its late and my brain is dead and therefore just can't come up with a reasonable solution.
Any help is appreciated.