4
I need to compare two arrays on Assert.Equals
.
When I test the method in race it is right but the test does not pass.
Code:
public void SeparaStringTest() {
RecebeComando recebecomando = new RecebeComando();
string[] StringSeparada = {
"A",
"A",
"B"
};
Assert.Equals(recebecomando.SeparaString("AAB"), StringSeparada);
Assert.Equals(recebecomando.SeparaString("A A B"), StringSeparada);
Assert.Equals(recebecomando.SeparaString("A-A-B"), StringSeparada);
}
public string[] SeparaString(string palavra) {
palavra = palavra.Replace("-", "");
palavra = palavra.Replace(" ", "");
var comando = new string[palavra.Length];
for (int i = 0; i < comando.Length; i++) {
comando[i] = palavra[i].ToString();
}
return comando;
}
@In your question you are also using the wrong method in comparison (as stated by Jbueno) is not Assert.Equals, but Assert.Areequals, more than anything, Collectionassert should be used for collections.
– Julio Borges