Exemple #1
0
        public void GreetingNotNull()
        {
            var greetingController = new GreetingController();

            _response = greetingController.Get();
            Assert.NotNull(_response);
        }
Exemple #2
0
        public void GreetingOkStatus()
        {
            var greetingController = new GreetingController();

            _response = greetingController.Get();
            Assert.IsInstanceOf <System.Web.Http.Results.OkNegotiatedContentResult <IEnumerable <IGreeting> > >(_response);
        }
Exemple #3
0
        public void Get_NoParams_StringReturnType()
        {
            var controller = new GreetingController();

            var response = controller.Get();

            Assert.IsType <String>(response);
        }
Exemple #4
0
        public void ShouldGetHelloWorldMessage()
        {
            var expected         = "Hello, World!";
            var greedingEndpoint = new GreetingController();

            var response = greedingEndpoint.Get();

            Assert.Equal(expected, response);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        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;
        }
Exemple #8
0
        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");
        }
Exemple #9
0
        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");
        }
Exemple #10
0
        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);
        }
Exemple #12
0
        public void Test_default_greet_value()
        {
            GreetingController greet = new GreetingController();

            Assert.Equal("say helloo", greet.Get());
        }
Exemple #13
0
        public void Test_greet_value_when_hi()
        {
            GreetingController greet = new GreetingController();

            Assert.Equal("hello", greet.Get("hi").Value);
        }