Example #1
0
        /// <inheritdoc/>
        public async Task <VisitItemEntityCollection> GetVisitItemEntityCollectionAsync(string shortUrl)
        {
            if (string.IsNullOrWhiteSpace(shortUrl))
            {
                throw new ArgumentNullException(nameof(shortUrl));
            }

            var container = await this._helper.GetContainerAsync().ConfigureAwait(false);

            var qb = new StringBuilder()
                     .Append("SELECT * FROM dvrl d WHERE d.collection = 'Visit' AND d.shortUrl = @shortUrl");
            var definition = new QueryDefinition(qb.ToString())
                             .WithParameter("@shortUrl", shortUrl);

            var collection = new VisitItemEntityCollection();

            using (var iterator = container.GetItemQueryIterator <VisitItemEntity>(definition))
            {
                while (iterator.HasMoreResults)
                {
                    foreach (var item in await iterator.ReadNextAsync().ConfigureAwait(false))
                    {
                        collection.Items.Add(item);
                    }
                }
            }

            return(collection);
        }
Example #2
0
        public void Given_Type_When_Instantiated_Then_It_Should_Return_Result()
        {
            var entity = new VisitItemEntityCollection();

            entity.Items.Should().NotBeNull()
            .And.HaveCount(0);
        }