Exemplo n.º 1
0
        public void CreateShowShouldPassTest()
        {
            StaticCache.LoadStaticCache();
            ShowController sc = new ShowController();

            var config  = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:22121/api/show/CreateShow");
            var route   = config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}",
                defaults: new { id = RouteParameter.Optional }
                );
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {
                { "controller", "show" }
            });

            sc.ControllerContext = new HttpControllerContext(config, routeData, request);
            request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var show = new ShawCodeExercise.Models.ShowModel();

            show.ID                  = 10;
            show.ShowName            = "the muppets";
            show.ShowCategories      = StaticCache.Categories;
            show.BackgroundImagePath = string.Empty;

            var response = sc.CreateShow(show);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
        }
Exemplo n.º 2
0
        public void CreateShowTestShouldFailTest()
        {
            StaticCache.LoadStaticCache();
            ShowController sc = new ShowController();

            var config  = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:22121/api/show/CreateShow");
            var route   = config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}",
                defaults: new { id = RouteParameter.Optional }
                );
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {
                { "controller", "show" }
            });

            sc.ControllerContext = new HttpControllerContext(config, routeData, request);
            request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            ShawCodeExercise.Models.ShowModel show = null;

            var response = sc.CreateShow(show);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.NotAcceptable);
        }
Exemplo n.º 3
0
        public async Task CreateShowTest()
        {
            var result = await _controller.CreateShow();

            Assert.IsNotNull(result);
        }