public void GivenThreePosts_TheAllPostsAppearInTheFeed()
        {
            _postRepository.Setup(p => p.GetBlogPosts("nickname")).Returns(new List <Post>
            {
                new Post(), new Post(), new Post()
            });
            var             feedService     = new SyndicationFeedService(_blogRepository.Object, _postRepository.Object);
            SyndicationFeed syndicationFeed = feedService.CreateSyndicationFeed("nickname", "feedtype", "scheme", "host");

            Assert.That(syndicationFeed.Items.Count(), Is.EqualTo(3));
        }
Example #2
0
        static void Main(string[] args)
        {
            var stopwatch = new Stopwatch();

            var logFile = "log.txt";

            stopwatch.Start();

            var fcsClientConfig = BuildConfig();

            var accessTokenProvider = new AccessTokenProvider(fcsClientConfig);

            var httpClient = new FcsHttpClientFactory(accessTokenProvider).Create();

            var syndicationFeedService = new SyndicationFeedService(httpClient);

            var fcsSyndicationFeedParserService = new FcsSyndicationFeedParserService(new XmlSerializationService());

            var contractMappingService = new ContractMappingService();

            var fcsFeedService = new FcsFeedService(syndicationFeedService, fcsSyndicationFeedParserService, contractMappingService);

            var existingSyndicationItemIds = new List <Guid>();

            using (var fcsContext = new FcsContext(fcsClientConfig.ConnectionString))
            {
                existingSyndicationItemIds = new FcsContractsPersistenceService(fcsContext).GetExistingSyndicationItemIds(CancellationToken.None).Result.ToList();
            }

            var fcsContracts = fcsFeedService.GetNewContractorsFromFeedAsync(fcsClientConfig.FeedUri + "/api/contracts/notifications/approval-onwards", existingSyndicationItemIds, CancellationToken.None).Result.ToList();

            File.AppendAllText(logFile, stopwatch.ElapsedMilliseconds + " ms - got FCS Contracts" + fcsContracts.Count);

            //var fcsContracts = fcsFeedService.LoadContractsFromFeedToEndAsync(fcsClientConfig.FeedUri + "/api/contracts/notifications/approval-onwards", CancellationToken.None).Result.ToList();

            File.AppendAllText(logFile, stopwatch.ElapsedMilliseconds + " ms - map to DC Contracts - " + fcsContracts.Count);

            //   var dcContracts = BuildMasterContracts(300);

            using (var fcsContext = new FcsContext(fcsClientConfig.ConnectionString))
            {
                fcsContext.Configuration.AutoDetectChangesEnabled = false;

                var fcsContractsPersistenceService = new FcsContractsPersistenceService(fcsContext);

                fcsContractsPersistenceService.PersistContracts(fcsContracts, CancellationToken.None).Wait();
            }

            File.AppendAllText(logFile, stopwatch.ElapsedMilliseconds + " ms - Persisted DC Contracts - " + fcsContracts.Count);
        }
        public void GivenAPost_TheTheItemContainsTheCorrectData()
        {
            _postRepository.Setup(p => p.GetBlogPosts("nickname")).Returns(new List <Post>
            {
                new Post
                {
                    Title    = "postTitle",
                    BlogPost = "body",
                    Edited   =
                        new DateTime(2010, 1, 1)
                }
            });
            var             feedService     = new SyndicationFeedService(_blogRepository.Object, _postRepository.Object);
            SyndicationFeed syndicationFeed = feedService.CreateSyndicationFeed("nickname", "feedtype", "scheme", "host");
            SyndicationItem item            = syndicationFeed.Items.FirstOrDefault();
            var             content         = (TextSyndicationContent)item.Content;

            Assert.That(item.Title.Text, Is.EqualTo("postTitle"));
            Assert.That(content.Text, Is.EqualTo("body"));
            Assert.That(item.PublishDate.DateTime, Is.EqualTo(new DateTime(2010, 1, 1)));
        }