public void GreetingNotNull() { var greetingController = new GreetingController(); _response = greetingController.Get(); Assert.NotNull(_response); }
public void GreetingOkStatus() { var greetingController = new GreetingController(); _response = greetingController.Get(); Assert.IsInstanceOf <System.Web.Http.Results.OkNegotiatedContentResult <IEnumerable <IGreeting> > >(_response); }
public void Get_NoParams_StringReturnType() { var controller = new GreetingController(); var response = controller.Get(); Assert.IsType <String>(response); }
public void ShouldGetHelloWorldMessage() { var expected = "Hello, World!"; var greedingEndpoint = new GreetingController(); var response = greedingEndpoint.Get(); Assert.Equal(expected, response); }
public void GreetingCheckName() { var greetingController = new GreetingController(); _response = greetingController.Get(); var response = _response as System.Web.Http.Results.OkNegotiatedContentResult <IEnumerable <IGreeting> >; var greetings = response.Content; Assert.AreEqual("Hello World", greetings.FirstOrDefault().Name); }
public void GreetingCount() { var greetingController = new GreetingController(); _response = greetingController.Get(); var response = _response as System.Web.Http.Results.OkNegotiatedContentResult <IEnumerable <IGreeting> >; var greetings = response.Content; Assert.AreEqual(1, greetings.Count()); }
public void Get_Specific_NonExistentId_ReturnsNotFound() { // Arrange this.mockGreetingService.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(() => null); // Act var controller = new GreetingController(this.mockGreetingService.Object); var result = controller.Get(Guid.NewGuid()).Result; // Assert var notFoundResult = result.Should().BeOfType <NotFoundResult>().Subject; }
public void Get_Success() { GreetingController controller = InitController(); ActionResult <IEnumerable <Greeting> > getResponse = controller.Get(); OkObjectResult okResult = Assert.IsType <OkObjectResult>(getResponse.Result); IEnumerable <Greeting> getResult = Assert.IsAssignableFrom <IEnumerable <Greeting> >(okResult.Value); Assert.True(getResult.Count() > 0); Assert.Contains(getResult, g => g.Name == "Hello World"); }
public void Get_WhenCalled_ReturnsOkResult() { // Arrange var expected = this.GetFakeGreetings(); this.mockGreetingService.Setup(x => x.GetAllItems()).Returns(() => expected); var controller = new GreetingController(this.mockGreetingService.Object); // Act var result = controller.Get().Result; // Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var greetings = okResult.Value.Should().BeAssignableTo <IEnumerable <Greeting> >().Subject; greetings.Count().Should().Be(3); greetings.ElementAt(0).Name.Should().Be("Hello ESDC"); }
public void Get_Specific_WhenCalled_ReturnsOkResult() { // Arrange var expected = new Greeting { Id = Guid.NewGuid(), Name = "Hello ESDC", Message = "Test 1", }; this.mockGreetingService.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(() => expected); // Act var controller = new GreetingController(this.mockGreetingService.Object); var result = controller.Get(expected.Id).Result; // Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var greeting = okResult.Value.Should().BeAssignableTo <Greeting>().Subject; greeting.Id.Should().Be(expected.Id); greeting.Name.Should().Be("Hello ESDC"); }
public void Test_For_Hi() { var response = _greeting.Get("hi").Value; Assert.Equal("hello", response); }
public void Test_default_greet_value() { GreetingController greet = new GreetingController(); Assert.Equal("say helloo", greet.Get()); }
public void Test_greet_value_when_hi() { GreetingController greet = new GreetingController(); Assert.Equal("hello", greet.Get("hi").Value); }