Example #1
0
        public void GetRequestReturns200StatusCodeIfSuccessful()
        {
            var userRepository = new UserRepository();
            var userService    = new UserService(userRepository);
            var controller     = new RootController(userService);

            var response = controller.HandleGetRequest();
            var actual   = response.StatusCode;

            Assert.Equal(200, actual);
        }
Example #2
0
        public void GetRequestReturnsDefaultGreetingResponse()
        {
            var userRepository = new UserRepository();
            var userService    = new UserService(userRepository);
            var controller     = new RootController(userService);

            var time     = DateTime.Now.ToString("%h:mm tt");
            var date     = DateTime.Now.ToString("%d MMMM yyyy");
            var expected = $"Hello Martyna - the time on the server is {time} on {date}";

            var response = controller.HandleGetRequest();
            var actual   = response.Body;

            Assert.Equal(expected, actual);
        }
Example #3
0
        public void GetRequestReturnsGreetingResponseWithFourNamesInList()
        {
            var userRepository = new UserRepository();
            var userService    = new UserService(userRepository);

            userService.AddUserToList("emile");
            userService.AddUserToList("marcelo");
            userService.AddUserToList("david");
            var controller = new RootController(userService);

            var time     = DateTime.Now.ToString("%h:mm tt");
            var date     = DateTime.Now.ToString("%d MMMM yyyy");
            var expected = $"Hello Martyna, Emile, Marcelo and David - the time on the server is {time} on {date}";

            var response = controller.HandleGetRequest();
            var actual   = response.Body;

            Assert.Equal(expected, actual);
        }