Пример #1
0
        public void AcceptsAbsoluteBaseUrl()
        {
            var baseUrl = "https://example.com";
            var service = new MockPaginationService(baseUrl, x => Task.FromResult(new HttpResponseMessage()));

            Assert.Equal(baseUrl, service.BaseUrl);
        }
Пример #2
0
        public void AcceptsRelativeBaseUrl()
        {
            var baseUrl = "/api/values";
            var service = new MockPaginationService(baseUrl, x => Task.FromResult(new HttpResponseMessage()));

            Assert.Equal(baseUrl, service.BaseUrl);
        }
Пример #3
0
 public Disposable()
 {
     _service = new MockPaginationService(string.Empty, x =>
     {
         _hasCalled = true;
         return(Task.FromResult(new HttpResponseMessage()));
     });
 }
Пример #4
0
 public UrlBuilder()
 {
     _service = new MockPaginationService(_baseUrl, x =>
     {
         _lastRequestedUrl = x;
         return(Task.FromResult(new HttpResponseMessage()));
     });
 }
Пример #5
0
 private void InitializeService()
 {
     _service = new MockPaginationService(string.Empty, x => Task.FromResult(_response));
     _service.PaginationResult.Subscribe(r =>
     {
         _hasRaisedNewPaginationResult = true;
         _receivedResult = r;
     });
 }
Пример #6
0
 private void InitializeServiceAndResetObservedValues(object payload = null)
 {
     _response = GetResponse(payload);
     _service  = new MockPaginationService(string.Empty, x => Task.FromResult(_response));
     _service.PaginationResult.Subscribe(r =>
     {
         _hasRaisedNewPaginationResult = true;
         _receivedResult = r;
     });
     _receivedResult = null;
     _hasRaisedNewPaginationResult = false;
 }
Пример #7
0
        public void SetsPropertiesFromDefaultOptions()
        {
            var service = new MockPaginationService(string.Empty, x => Task.FromResult(new HttpResponseMessage()), new DefaultPaginationOptions
            {
                Page           = 12,
                PageSize       = 4,
                SortDescending = true,
                SortProperty   = "Name"
            });

            Assert.Equal(12, service.Page);
            Assert.Equal(4, service.PageSize);
            Assert.True(service.SortDescending);
            Assert.Equal("Name", service.SortProperty);
        }
Пример #8
0
 private void InitializeService()
 {
     _service = new MockPaginationService(string.Empty, x =>
     {
         var response            = GetResponse();
         var parsedQuery         = QueryHelpers.ParseQuery(x);
         _lastCalledResponsePage = Convert.ToInt32(parsedQuery["page"]);
         if (_firstCalledResponsePage == default)
         {
             _firstCalledResponsePage = _lastCalledResponsePage;
         }
         return(Task.FromResult(response));
     }, new DefaultPaginationOptions {
         Page = _initialResponsePage
     });
 }
Пример #9
0
            public void CallsOnInitializationWithCustomOptions()
            {
                _service = new MockPaginationService(_baseUrl, x =>
                {
                    _lastRequestedUrl = x;
                    return(Task.FromResult(new HttpResponseMessage()));
                }, new DefaultPaginationOptions
                {
                    Page           = 3,
                    PageSize       = 17,
                    SortDescending = true,
                    SortProperty   = "Name"
                });
                var expectedUrl = $"{_baseUrl}?page=3&pageSize=17&sort=Name%20desc";

                Assert.Equal(expectedUrl, _lastRequestedUrl);
            }
Пример #10
0
        public void AcceptsEmptyBaseUrl()
        {
            var service = new MockPaginationService(string.Empty, x => Task.FromResult(new HttpResponseMessage()));

            Assert.NotNull(service);
        }
Пример #11
0
        public void SetsBaseUrlToStringEmptyForEmptyBaseUrl()
        {
            var service = new MockPaginationService(null, x => Task.FromResult(new HttpResponseMessage()));

            Assert.Equal(string.Empty, service.BaseUrl);
        }
Пример #12
0
 public RequestRunningNotifications()
 {
     _service = new MockPaginationService(string.Empty, x => Task.FromResult(new HttpResponseMessage()));
     _service.RequestRunning.Subscribe(isRunning => _isRunningEvents.Add(isRunning));
 }