I've been having a frustrating time this morning trying to use the Visual Studio 2008 Professional Unit Testing framework. For some reason an Assert is failing that shouldn't be as far as I can tell.
Here's what I'm working with, in simplified version:
int[,] expected = { { 10, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 10 } };
int[,] wtfexpected = { { 10, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 10 } };
Assert.AreEqual(expected, wtfexpected);
This returns:
Assert.AreEqual failed. Expected:<System.Int32[,]>. Actual:<System.Int32[,]>.
I can replace the last line with:
Assert.AreEqual<int[,]>(expected, wtfexpected);
And it does not change the result.
However if I use my target object's property 'stones' of type int[,] instead:
BoardState target = new BoardState();
int[,] expected = { { 10, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 10 } };
int[,] actual;
target.Stones = expected;
actual = target.Stones;
Assert.AreEqual(expected, actual);
The assert works.
Here's some code from in my BoardState class:
public class BoardState
{
private int[,] stonesDistribution;
public BoardState()
{
//initialize the board
//stones array shows where the stones are
stonesDistribution = new int[4,4]{ { 10, 0, 0, 0 } , { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 10 } };
}
public int[,] Stones
{
get
{
return stonesDistribution;
}
set
{
stonesDistribution = value;
}
}
}
Can anybody help me out?

New Topic/Question
Reply




MultiQuote



|