public void CreateCategoryShouldPassTest()
        {
            StaticCache.LoadStaticCache();
            VideoController vc = new VideoController();

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

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

            ShawCodeExercise.Models.VideoModel video = new ShawCodeExercise.Models.VideoModel()
            {
                ID          = 6,
                Title       = "Mock title",
                Description = "Mock Description",
                SeasonNo    = "S012",
                EpisodeNo   = "E01",
                IsLocked    = false,
            };

            var response = vc.CreateVideo(video);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void CreateVideoExistingShouldFailTest()
        {
            StaticCache.LoadStaticCache();
            VideoController vc = new VideoController();

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

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

            ShawCodeExercise.Models.VideoModel video = new ShawCodeExercise.Models.VideoModel()
            {
                ID          = 1,
                Title       = "video 1 title",
                Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Hic ambiguo ludimur. Que Manilium, ab iisque M. Efficiens dici potest. Falli igitur possumus. Quae sequuntur igitur? Duo Reges: constructio interrete.",
                SeasonNo    = "S012",
                EpisodeNo   = "E01",
                IsLocked    = false,
            };

            var response = vc.CreateVideo(video);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Conflict);
        }
Ejemplo n.º 4
0
        public void GetShowDataIDExistsShouldPassTest()
        {
            StaticCache.LoadStaticCache();
            ShowController sc = new ShowController();

            var config  = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:22121/api/show/GetShowData");
            var route   = config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                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 response = sc.GetShowData(1);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);

            response = sc.GetShowData(100);
            Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     BundleTable.EnableOptimizations = true;
     StaticCache.LoadStaticCache();
 }
Ejemplo n.º 7
0
        protected void Application_Start()
        {
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            // AreaRegistration.RegisterAllAreas();
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            StaticCache.LoadStaticCache();
        }
Ejemplo n.º 8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configuration.Filters.Add(new ValidationActionFilter());
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            RegisterUserDB();
            WeNeedUHaveBundler.PerformBundling();

            //This is API validation and logging. Turn on when necessary
            //var webApiUsageService = DependencyResolver.Current.GetService<IWebApiUsageService>();
            //GlobalConfiguration.Configuration.MessageHandlers.Add(new WebApiUsageHandler(webApiUsageService));
            //GlobalConfiguration.Configuration.MessageHandlers.Add(new WebApiKeyHandler(webApiUsageService));

            StaticCache.LoadStaticCache();
        }
Ejemplo n.º 9
0
        private void LoadData()
        {
            var file = Server.MapPath(Convert.ToBoolean(ConfigurationManager.AppSettings["UseSmallDataSample"]) ? "~/App_Data/data_small.json" : "~/App_Data/data_large.json");

            StaticCache.LoadStaticCache(file);
        }
Ejemplo n.º 10
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     StaticCache.LoadStaticCache();
 }