コード例 #1
0
ファイル: Global.asax.cs プロジェクト: jonezy/Podcast
        private IContainer RegisterDependencies()
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            builder.Register(c =>
            {
                var connectionString = ConfigurationManager.ConnectionStrings["PodcastTracking"].ConnectionString;
                var context = new PodcastTrackingContext(connectionString);
                context.Database.Initialize(false);

                return context;
            }).InstancePerRequest();

            builder.RegisterType<EpisodeRepository>().As<IEpisodeRepository>();
            builder.RegisterType<PodcastRepository>().As<IPodcastRepository>();
            builder.RegisterType<PublisherRepository>().As<IPublisherRepository>();
            builder.RegisterType<FeedRepository>().As<IFeedRepository>();

            builder.RegisterType<FeedLoader>().As<IFeedLoader>();
            builder.RegisterType<EpisodeParser>().As<IMultipleFeedParser<Episode>>();
            builder.RegisterType<PodcastParser>().As<IFeedParser<Podcast>>();
            builder.RegisterType<PublisherParser>().As<IFeedParser<Publisher>>();

            builder.RegisterType<PodcastService>().As<IPodcastService>();
            builder.RegisterType<FeedImportingService>().As<IFeedImportingService>();
            builder.RegisterType<FeedGenerator>().As<IFeedGenerator>();
            builder.RegisterType<EpisodeService>().As<IEpisodeService>();
            builder.RegisterType<FeedService>().As<IFeedService>();

            return builder.Build();
        }
コード例 #2
0
ファイル: DataTests.cs プロジェクト: jonezy/Podcast
        public void SetUp()
        {
            _context = new PodcastTrackingContext(ConfigurationManager.ConnectionStrings["PodcastTrackingTest"].ConnectionString);
            _context.Database.Initialize(true);

            var publisher = new Publisher
            {
                Name = "The 416",
                Website = "http://the416.net",
                Podcasts = new List<Podcast> {
                    new Podcast
                    {
                        Title = "The 416 Show",
                        FeedUrl = "http://the416.net/416/rss/",
                        Description = "A show about topics and things",
                        LastUpdated = DateTime.Now.AddDays(-5),
                        Episodes = new List<Episode> {
                            new Episode {
                                EpisodeUrl = "http://the416.net/416/20",
                                Author = "Chris",
                                EpisodeDownloadUrl="http://the416.net/416/EP20.mp3",
                                Description="EPisode 20 description",
                                Downloads = new List<Download>()
                                {
                                    new Download {
                                        DownloadId = 1,
                                        IPAddress = "10.0.0.1",
                                        DateTime = DateTime.Now
                                    }
                                },
                                PublishDate=DateTime.Now.AddDays(-7),
                                Title="Episode 20: Writing the unit tests"
                            }
                        }
                    }
                }
            };

            _context.Publishers.Add(publisher);
            _context.SaveChanges();
        }