コード例 #1
0
        public SilkveilContainerTests()
        {
            var containerBuilder = new ContainerBuilder();
            containerBuilder.Register(typeof(IContainerBinder), typeof(ContainerBinder));
            containerBuilder.Register(typeof(IRequestListener), typeof(DownloadRequestListener));
            containerBuilder.Register(typeof(IRequestListener), typeof(RedirectRequestListener));
            containerBuilder.Register(typeof(IMappingResolver<IDownloadMapping>), typeof(DownloadMappingResolver));
            containerBuilder.Register(typeof(IMappingResolver<IRedirectMapping>), typeof(RedirectMappingResolver));
            containerBuilder.Register<IMappingProvider<IDownloadMapping>>(
                c =>
                {
                    var downloadMappingProvider = new DownloadMappingProvider(c);
                    downloadMappingProvider.Initialize();
                    return downloadMappingProvider;
                });
            containerBuilder.Register<IMappingProvider<IRedirectMapping>>(
                c =>
                {
                    var redirectMappingProvider = new RedirectMappingProvider(c);
                    redirectMappingProvider.Initialize();
                    return redirectMappingProvider;
                });
            containerBuilder.Register(typeof(IContentSource), typeof(HttpContentSource));
            containerBuilder.Register(typeof(IContentSource), typeof(FileContentSource));
            containerBuilder.Register(typeof(IStreamSplitter), typeof(StreamSplitter));
            containerBuilder.Register(typeof(IHttpStreamFactory), typeof(HttpStreamFactory));
            containerBuilder.Register(typeof(ISilkveilContainer), typeof(SilkveilContainer));

            containerBuilder.Register(typeof(IDownloadMapping), typeof(DownloadMapping));
            containerBuilder.Register(typeof(IRedirectMapping), typeof(RedirectMapping));

            this._container = containerBuilder.Build();
        }
コード例 #2
0
        public SilkveilContainerTests()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.Register(typeof(IContainerBinder), typeof(ContainerBinder));
            containerBuilder.Register(typeof(IRequestListener), typeof(DownloadRequestListener));
            containerBuilder.Register(typeof(IRequestListener), typeof(RedirectRequestListener));
            containerBuilder.Register(typeof(IMappingResolver <IDownloadMapping>), typeof(DownloadMappingResolver));
            containerBuilder.Register(typeof(IMappingResolver <IRedirectMapping>), typeof(RedirectMappingResolver));
            containerBuilder.Register <IMappingProvider <IDownloadMapping> >(
                c =>
            {
                var downloadMappingProvider = new DownloadMappingProvider(c);
                downloadMappingProvider.Initialize();
                return(downloadMappingProvider);
            });
            containerBuilder.Register <IMappingProvider <IRedirectMapping> >(
                c =>
            {
                var redirectMappingProvider = new RedirectMappingProvider(c);
                redirectMappingProvider.Initialize();
                return(redirectMappingProvider);
            });
            containerBuilder.Register(typeof(IContentSource), typeof(HttpContentSource));
            containerBuilder.Register(typeof(IContentSource), typeof(FileContentSource));
            containerBuilder.Register(typeof(IStreamSplitter), typeof(StreamSplitter));
            containerBuilder.Register(typeof(IHttpStreamFactory), typeof(HttpStreamFactory));
            containerBuilder.Register(typeof(ISilkveilContainer), typeof(SilkveilContainer));

            containerBuilder.Register(typeof(IDownloadMapping), typeof(DownloadMapping));
            containerBuilder.Register(typeof(IRedirectMapping), typeof(RedirectMapping));

            this._container = containerBuilder.Build();
        }
コード例 #3
0
        public void InitializeCreatesMappingForSilkveilWebsite()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);

            int count = 0;

            redirectMappingProvider.MappingsAvailable += r =>
            {
                Assert.That(r.Count(), Is.EqualTo(1));
                Assert.That(r.First().Guid, Is.EqualTo(Guid.Empty));
                Assert.That(r.First().Uri, Is.EqualTo(new Uri("http://www.silkveil.net")));
                Assert.That(r.First().RedirectType, Is.EqualTo(RedirectType.Permanent));
                count++;
            };

            redirectMappingProvider.Initialize();
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }
コード例 #4
0
        public void InitializeCreatesMappingForSilkveilWebsite()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);

            int count = 0;
            redirectMappingProvider.MappingsAvailable += r =>
                                                     {
                                                         Assert.That(r.Count(), Is.EqualTo(1));
                                                         Assert.That(r.First().Guid, Is.EqualTo(Guid.Empty));
                                                         Assert.That(r.First().Uri, Is.EqualTo(new Uri("http://www.silkveil.net")));
                                                         Assert.That(r.First().RedirectType, Is.EqualTo(RedirectType.Permanent));
                                                         count++;
                                                     };

            redirectMappingProvider.Initialize();
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }