public void GetByIdTest() { // Arrange ChatController controller = new ChatController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var id = Setup(); // Act var response = controller.Get(id); var contentResult = response.Content; // Assert the result Assert.IsNotNull(contentResult); if (response != null) { var jsonString = response.Content.ReadAsStringAsync(); JObject json = JObject.Parse(jsonString.Result); Assert.AreEqual("tester", json["username"]); } CleanupDB(id); response.Dispose(); }
public void For_any_other_intut_print_the_defalut_message() { var controller = new ChatController(); string expected = "I don't know what are you talking about"; string actual = controller.Get("gjlkdjl"); Assert.Equal(expected, actual); //controller.Get("abc").Should().Be("I don't know what are you talking about"); }
public void Get() { // Arrange ChatController controller = new ChatController(); // Act IEnumerable <string> result = controller.Get(); // Assert Assert.IsNotNull(result); Assert.AreEqual(2, result.Count()); Assert.AreEqual("value1", result.ElementAt(0)); Assert.AreEqual("value2", result.ElementAt(1)); }
public void If_user_enters_Hello_it_should_return_Hi() { var controller = new ChatController(); controller.Get("hello").Should().Be("hi"); }