public void TestSetPositionResponseNotNull() { Sonda sonda = new Sonda(); sonda.SetPosition(); string returnTest = HttpContext.Current.Response.Output.ToString(); Assert.IsNotNull(returnTest); }
public void TestSetPosition() { List <Object> movementsPerformed = new List <Object>(); movementsPerformed.Add("girou para a esquerda"); movementsPerformed.Add("se moveu 3 vez(es) no eixo X"); movementsPerformed.Add("girou para a direita"); movementsPerformed.Add("se moveu 2 vez(es) no eixo Y"); List <Object> position = new List <Object> { new { x = "3" }, new { y = "2" }, new { face = "D" }, new { movementsPerformed = movementsPerformed } }; Object expectedReturnJSON = new { position }; string expectedReturn = (new JavaScriptSerializer()).Serialize(expectedReturnJSON); Sonda sonda = new Sonda(); sonda.SetPosition(); string returnTest = HttpContext.Current.Response.Output.ToString(); Assert.AreEqual(expectedReturn, returnTest); }
public void TestSetPositionInvalid() { TestSetupCoordinatesInvalid(); Object expectedReturnJSON = new { error = "Um movimento inválido foi detectado, infelizmente a sonda ainda não possui a habilidade de voar." }; string expectedReturn = (new JavaScriptSerializer()).Serialize(expectedReturnJSON); Sonda sonda = new Sonda(); sonda.SetPosition(); string returnTest = HttpContext.Current.Response.Output.ToString(); Assert.AreEqual(expectedReturn, returnTest); }