Exemple #1
0
        public void WhenCurrentFeedIsFull_ThenReturnANewFeed()
        {
            var getWorkingFeedForTopic = new GetWorkingFeedForTopic(connectionString);
            var oldFeed = new Feed
            {
                Updated = DateTime.UtcNow.AddMinutes(-2),
                TopicId = topic.Id.Value
            };
            var currentFeed = new Feed
            {
                Updated = DateTime.UtcNow.AddMinutes(-1),
                TopicId = topic.Id.Value,
                Entries = Enumerable.Range(0, 10)
                          .Select(i => new FeedEntry {
                    MessageId = Identity.Random(12)
                })
                          .ToList()
            };

            mongoDb.GetCollectionByType <Feed>()
            .InsertMany(oldFeed, currentFeed);

            var read = getWorkingFeedForTopic.Execute(topic.Id.Value);

            read.Should().Not.Be.EqualTo(currentFeed);
            read.PreviousFeed.ToString().Should().Be.EqualTo(currentFeed.Id.ToString());

            mongoDb.GetCollectionByType <Feed>()
            .FindById(currentFeed.Id.Value)
            .NextFeed.ToString().Should().Be.EqualTo(read.Id.ToString());
        }
Exemple #2
0
        public void WhenThereIsNoFeed_ThenCreateSaveAndReturnANewOne()
        {
            var getWorkingFeedForTopic = new GetWorkingFeedForTopic(connectionString);
            var feed = getWorkingFeedForTopic.Execute(topic.Id.Value);

            feed.Satisfy(t => t.TopicId == topic.Id && t.Entries.Count == 0 && !t.PreviousFeed.HasValue);
        }
Exemple #3
0
        public void WhenCurrentFeedIsNotFull_ThenReturnThatFeed()
        {
            var getWorkingFeedForTopic = new GetWorkingFeedForTopic(connectionString);
            var oldFeed = new Feed
            {
                Updated = DateTime.UtcNow.AddMinutes(-2),
                TopicId = topic.Id.Value
            };
            var currentFeed = new Feed
            {
                Updated = DateTime.UtcNow.AddMinutes(-1),
                TopicId = topic.Id.Value
            };

            mongoDb.GetCollectionByType <Feed>()
            .InsertMany(oldFeed, currentFeed);

            var read = getWorkingFeedForTopic.Execute(topic.Id.Value);

            read.Should().Be.EqualTo(currentFeed);
        }