示例#1
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();
            var constraintResolver   = new DefaultInlineConstraintResolver()
            {
                ConstraintMap =
                {
                    ["apiVersion"] = typeof(ApiVersionRouteConstraint)
                }
            };

            config.MapHttpAttributeRoutes(constraintResolver);

            config.AddApiVersioning();

            app.UseWebApi(config);

            config
            .EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "Diff API - Andrew Signori");
                c.IncludeXmlComments($"{System.AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\Diff.XML");
            })
            .EnableSwaggerUi(c => c.DocExpansion(DocExpansion.List));

            config.DependencyResolver = DependencyRegistrations.GetDependencyResolver();
        }
示例#2
0
        public void Initialize()
        {
            IDependencyResolver dependencyResolver = DependencyRegistrations.GetDependencyResolver();

            // While creating the controller for tests we could use a different repository speficic
            // for tests, but here the ideia is use the same for the exercise purposes.
            _diffController = (DiffController)dependencyResolver.GetService(typeof(DiffController));
            _repository     = (IRepository)dependencyResolver.GetService(typeof(IRepository));
            _repository.ClearData();
        }