Ejemplo n.º 1
0
        public void Check_Response_of_Hello_for_hello()
        {
            HelloController hc     = new HelloController();
            string          result = hc.Get("Hello");

            result.Should().Be("Hi");
        }
Ejemplo n.º 2
0
        public void NoInputParamGetResponseTest()
        {
            HelloController controller = new HelloController();
            var             response   = controller.Get().Value as Response;

            Assert.Equal("2Hello World!", response.output);
        }
Ejemplo n.º 3
0
        public void Hello_Response()
        {
            HelloController valuesController = new HelloController();
            string          result           = valuesController.Get("Hello");

            result.Should().Be("Hii");
        }
Ejemplo n.º 4
0
        public void Check_Response_of_Hello_for_other_than_hello()
        {
            HelloController hc     = new HelloController();
            string          result = hc.Get("Hii");

            result.Should().Be("Say Hello...");
        }
Ejemplo n.º 5
0
        public void InputParamGetResponseTest(string inputValue, string expectedOutput)
        {
            HelloController controller = new HelloController();
            var             response   = controller.Get(inputValue).Value as Response;

            Assert.Equal(expectedOutput, response.output);
        }
Ejemplo n.º 6
0
        public void StringValidation()
        {
            var HelloCo = new HelloController();
            var Output  = HelloCo.Get();

            Assert.AreEqual("Hello World", Output);
        }
Ejemplo n.º 7
0
        public void StringValidation()
        {
            var controller = new HelloController();
            var result     = controller.Get();

            Assert.AreEqual("Hello World", result);
        }
Ejemplo n.º 8
0
        public void NullStringGetReturnsBadRequest()
        {
            var helloController = new HelloController(Mock.Of <IBirthdayRepository>(), Mock.Of <IBirthdayCalculator>());

            var getResult = helloController.Get(null).Result;

            Assert.IsType <BadRequestObjectResult>(getResult);
        }
        public void NoInputParamGetResponseTest()
        {
            HelloController controller = new HelloController();
            var             response   = controller.Get().Value as Response;

            Assert.Equal("Hello World!", response.Output);
            assertFalse("fail", false);
        }
Ejemplo n.º 10
0
        public void GetShouldReturnResponse()
        {
            var controller = new HelloController();

            var response = controller.Get() as OkNegotiatedContentResult <HelloResponse>;;

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Content.Data.Contains("Hello there!!"));
        }
Ejemplo n.º 11
0
        public void GetHello_ShouldForceError()
        {
            var controller = new HelloController();

            //Pass forceError = true
            var actionResult = controller.Get(true) as IHttpActionResult;

            Assert.IsNotNull(actionResult);
            Assert.IsInstanceOfType(actionResult, typeof(ExceptionResult));
        }
Ejemplo n.º 12
0
        public void GetTest()
        {
            //arrange
            string expectedGreeting = "Hello World";

            //act
            HelloController hc = new HelloController(new HelloGreeting());

            //asset
            Assert.Equal(expectedGreeting, hc.Get());
        }
Ejemplo n.º 13
0
        public void GetById()
        {
            // Arrange
            var controller = new HelloController();

            // Act
            var result = controller.Get(5);

            // Assert
            Assert.AreEqual("Hello World", result.Message);
        }
        public void Get_Returns_JSON_Value()
        {
            // Arrange
            var controller = new HelloController();

            // Act
            var okResult = controller.Get();

            // Assert
            Assert.IsType <Dictionary <string, string> >(okResult);
            Assert.Equal(1, okResult.Count);
            Assert.Equal("hello, world", okResult["Output"]);
        }
Ejemplo n.º 15
0
        public void Get()
        {
            // Arrange
            var controller = new HelloController();

            // Act
            IEnumerable <HelloModel> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("Hello World", result.ElementAt(0).Message);
        }
Ejemplo n.º 16
0
        public void Get()
        {
            // Arrange
            HelloController controller = new HelloController();

            // Act
            IEnumerable <string> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("Hello", result.ElementAt(0));
            Assert.AreEqual("World", result.ElementAt(1));
        }
Ejemplo n.º 17
0
        public void GetHello_ShouldReturnValue()
        {
            var testHello  = new HelloClass();
            var controller = new HelloController();

            var actionResult  = controller.Get() as IHttpActionResult;
            var contentResult = actionResult as OkNegotiatedContentResult <HelloClass>;

            Assert.IsNotNull(actionResult);

            //Times should be very close
            var ts = DateTime.Parse(contentResult.Content.CurrentDateTime) - DateTime.Parse(testHello.CurrentDateTime);

            Assert.IsTrue(Math.Abs(ts.TotalMilliseconds) < 100);
        }
        public void GetHello_ReturnsHelloString()
        {
            // Arrange
            var mockService = new Mock <IMessageService>();

            mockService.Setup(service => service.GetMessageText(1)).Returns("Test Success");

            var controller = new HelloController(mockService.Object);

            // Act
            var result = controller.Get();

            // Assert
            Assert.AreEqual(result, "Test Success");
        }
        public void Get_ShouldCallTheService()
        {
            // Arrange
            var    mockService    = Substitute.For <IHelloService>();
            var    controller     = new HelloController(mockService);
            string expectedResult = "test";

            mockService.SayHello().Returns(expectedResult);

            // Act
            var result = controller.Get().Value;

            // Assert
            Assert.Equal(expectedResult, result);
            mockService.Received(requiredNumberOfCalls: 1).SayHello();
        }
Ejemplo n.º 20
0
        public void SuccessfulGet_BirthdayToday_ReturnsMessageAndOk()
        {
            var      mockBirthdayRepository = new Mock <IBirthdayRepository>();
            DateTime dateOfBirth;

            mockBirthdayRepository.Setup(br => br.TryGetDateOfBirth(It.IsAny <string>(), out dateOfBirth))
            .Returns(true);
            var mockBirthdayCalculator = new Mock <IBirthdayCalculator>();

            mockBirthdayCalculator.Setup(bd => bd.DaysUntilNextBirthday(It.IsAny <DateTime>())).Returns(0);
            var helloController = new HelloController(mockBirthdayRepository.Object, mockBirthdayCalculator.Object);

            var getResult = helloController.Get("Connor").Result;

            var okObjectResult = Assert.IsType <OkObjectResult>(getResult);
            var actual = okObjectResult.Value.ToString();
            var expected = new { Message = "Hello, Connor! Happy Birthday!" }.ToString();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 21
0
        public void HelloCoreTest()
        {
            var hc = new HelloController();

            Assert.Equal("Hello from Core 2.0", hc.Get());
        }
Ejemplo n.º 22
0
 public void Test1()
 {
     Assert.NotEmpty(HC.Get());
 }
Ejemplo n.º 23
0
        public void GetTestName()
        {
            HelloController c = new HelloController();

            Assert.AreEqual("Hello Ralph", c.Get("Ralph"));
        }
        public void hello_controller_noinput_tests()
        {
            HelloController hello = new HelloController();

            Assert.Equal("Hi", hello.Get().Value);
        }
        public void hello_controller_nameinput_tests()
        {
            HelloController hello = new HelloController();

            Assert.Equal("Hi Raunak", hello.Get("Raunak").Value);
        }
Ejemplo n.º 26
0
        public void Visiting_hello_route_returns_hi()
        {
            var controller = new HelloController();

            controller.Get().Should().BeEquivalentTo((ActionResult <IEnumerable <string> >) new string[] { "Hi" });
        }
Ejemplo n.º 27
0
        public void Visiting_hello_slash_name_route_returns_hi_name()
        {
            var controller = new HelloController();

            controller.Get("RV").Should().Be("Hi RV");
        }
Ejemplo n.º 28
0
        public void Hello_Parameter_Should_Return_Hi_Test()
        {
            HelloController hello = new HelloController();

            Assert.Equal("Hi", hello.Get("Hello").Value);
        }
Ejemplo n.º 29
0
        public void Default_Value_Test()
        {
            HelloController hello = new HelloController();

            Assert.Equal("Say Hello or Hi First", hello.Get("abcd").Value);
        }
Ejemplo n.º 30
0
        public void No_Parameter_Should_Return_BYE_Test()
        {
            HelloController hello = new HelloController();

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