Ejemplo n.º 1
0
        public void ReturnsEmptyDictionaryWhenNoPropertiesSupplied()
        {
            // given
            var subject = new FakePageRequest();

            // when
            var result = subject.ToReadOnlyDictionary();

            // then
            Assert.That(result, Is.Empty);
        }
Ejemplo n.º 2
0
        public void UsesQueryParamKeyWhenAttributeSupplied()
        {
            // given
            var expected = DateTimeOffset.UtcNow;
            var subject  = new FakePageRequest
            {
                CreatedGreaterThanOrEqual = expected
            };

            // when
            var result = subject.ToReadOnlyDictionary();

            // then
            Assert.That(result["created_at[gte]"], Is.EqualTo(expected));
        }
Ejemplo n.º 3
0
        public void InitialRequestIsNullThrows()
        {
            // given
            Func <FakePageRequest, Task <PagedResponse <string> > > pager = _ => Task.FromResult(new PagedResponse <string>());
            var subject = new Pager <FakePageRequest, string>(pager);

            FakePageRequest initialRequest = null;

            // when
            TestDelegate test = () => subject.StartFrom(initialRequest);

            // then
            var ex = Assert.Throws <ArgumentNullException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(initialRequest)));
        }
Ejemplo n.º 4
0
        public void PreservesCaseOfValues()
        {
            // given
            var subject = new FakePageRequest
            {
                Before = "BEFORE teSt",
                After  = "AFTER teSt"
            };

            // when
            var result = subject.ToReadOnlyDictionary();

            // then
            Assert.That(result["before"], Is.EqualTo("BEFORE teSt"));
            Assert.That(result["after"], Is.EqualTo("AFTER teSt"));
        }
Ejemplo n.º 5
0
        public void ExcludesNullProperties()
        {
            // given
            var subject = new FakePageRequest
            {
                Before = "before test",
                Limit  = 5
            };

            // when
            var result = subject.ToReadOnlyDictionary();

            // then
            Assert.That(result.Keys.Count(), Is.EqualTo(2));
            Assert.That(result["before"], Is.EqualTo("before test"));
            Assert.That(result["limit"], Is.EqualTo(5));
        }
Ejemplo n.º 6
0
        public void IncludesAllSuppliedProperties()
        {
            // given
            var subject = new FakePageRequest
            {
                Before = "before test",
                After  = "after test",
                Limit  = 5
            };

            // when
            var result = subject.ToReadOnlyDictionary();

            // then
            Assert.That(result.Keys.Count(), Is.EqualTo(3));
            Assert.That(result["before"], Is.EqualTo("before test"));
            Assert.That(result["after"], Is.EqualTo("after test"));
            Assert.That(result["limit"], Is.EqualTo(5));
        }