Ejemplo n.º 1
0
        public void SetUp()
        {
            _context = HttpContextBuilder.MockHttpContext();
            _authoriser = new Mock<IAuthoriser>();
            _specificPackageInstaller = new Mock<IPackageInstaller>();

            IDictionary<string, Action<HttpContextBase>> httpMethodActions = new Dictionary<string, Action<HttpContextBase>>
            {
                { "GET",  c => _specificPackageInstaller.Object.Execute() },
            };

            _packageInstaller = new PackageInstaller(_context.Object, _authoriser.Object, httpMethodActions);
        }
        public static IPackageInstaller Build(HttpContextBase httpContext)
        {
            var configurationProvider = new PackageInstallationConfigurationProvider();
            var packageRunner = new PackageRunner();

            IPackageInstaller serverPackageInstaller = new ServerPackageFileInstaller(httpContext, packageRunner);
            IPackageInstaller streamedPackageInstaller = new StreamedPackageInstaller(httpContext, packageRunner);

            IDictionary<string, Action<HttpContextBase>> httpMethodActions = new Dictionary<string, Action<HttpContextBase>>
            {
                { "GET",  c => serverPackageInstaller.Execute() },
                { "POST", c => streamedPackageInstaller.Execute() }
            };

            var packageInstaller = new PackageInstaller(httpContext,
                                                        new HttpRequestAuthoriser(httpContext, configurationProvider),
                                                        httpMethodActions);
            return packageInstaller;
        }