Пример #1
0
        public async void GetMazebotRandom_Should_Call_IApiRequestProvider_CreateGetRequest()
        {
            Dictionary <string, string> queries = null;

            _requestProvider.CreateGetRequest(Arg.Any <string>(), Arg.Any <Dictionary <string, string> >(), Arg.Do <Dictionary <string, string> >(a => queries = a));

            await _client.GetMazebotRandom(null, null);

            _requestProvider.Received(1).CreateGetRequest($"{_noopsUrl}/mazebot/random", Arg.Any <Dictionary <string, string> >(), Arg.Any <Dictionary <string, string> >());
            queries.Should().BeEmpty();
        }
Пример #2
0
        public async void SearchIllnesses_Should_Call_IApiRequestProvider_CreateGetRequest(int?itemsPerPage, int?pageIndex, string expectedLimit, string expectedPage)
        {
            var details = new SearchIllnessesRequest
            {
                ItemsPerPage = itemsPerPage,
                PageIndex    = pageIndex
            };
            await _repository.SearchIllnesses(details);

            var query = new List <string>();

            if (expectedLimit != null)
            {
                query.Add($"limit={expectedLimit}");
            }
            if (expectedPage != null)
            {
                query.Add($"page={expectedPage}");
            }
            var queryString = query.Any() ? $"?{string.Join("&", query)}" : string.Empty;

            var url = $"{_database}/illnesses{queryString}";

            _requestProvider.Received(1).CreateGetRequest(url);
        }
Пример #3
0
        public void GetImage_Should_Call_IApiRequestProvider_CreateGetRequest()
        {
            _requestProvider.CreateGetRequest(Arg.Any <string>(), Arg.Any <Dictionary <string, string> >(), Arg.Any <Dictionary <string, string> >());

            var imageUrl = "imageUrl";

            _client.GetImage <Rgb24>(imageUrl);

            _requestProvider.Received(1).CreateGetRequest(imageUrl, Arg.Any <Dictionary <string, string> >(), Arg.Any <Dictionary <string, string> >());
        }
        public async void SignUp_Should_Call_IApiRequestProvider_CreatePostRequest()
        {
            JObject content = null;
            Dictionary <string, string> query = null;

            _requestProvider.CreatePostRequest(Arg.Any <string>(), Arg.Do <JObject>(a => content = a), Arg.Any <Dictionary <string, string> >(), Arg.Do <Dictionary <string, string> >(a => query = a), Arg.Any <Func <JObject, HttpContent> >());

            var request = new SecurityRequest
            {
                Email    = "email",
                Password = "******"
            };
            await _provider.SignUp(request);

            _requestProvider.Received(1).CreatePostRequest($"{_firebaseAuthEndpoint}/accounts:signUp", Arg.Any <JObject>(), Arg.Any <Dictionary <string, string> >(), Arg.Any <Dictionary <string, string> >(), null);

            content.Value <string>("email").Should().Be(request.Email);
            content.Value <string>("password").Should().Be(request.Password);
            content.Value <bool>("returnSecureToken").Should().BeTrue();

            query.Should().ContainKey("key");
            query["key"].Should().Be(_firebaseApiKey);
        }
        public async void GetRemarks_Should_Call_IApiRequestProvider_CreatePostRequest()
        {
            JObject content = null;
            Dictionary <string, string> header = null;

            _requestProvider.CreatePostRequest(Arg.Any <string>(), Arg.Do <JObject>(a => content = a), headers: Arg.Do <Dictionary <string, string> >(a => header = a));

            await _repository.GetRemarks();

            _requestProvider.Received(1).CreatePostRequest($"{_firebaseDatabase}/projects/{_firebaseProjectId}/databases/(default)/documents:runQuery", Arg.Any <JObject>(), headers: Arg.Any <Dictionary <string, string> >());

            content.Should().ContainKey("structuredQuery");
            content.SelectToken("structuredQuery").Value <JObject>().Should().ContainKey("select");
            content.SelectToken("structuredQuery.select").Value <JObject>().Should().ContainKey("fields");
            content.SelectToken("structuredQuery.select.fields").Value <JArray>().Should().HaveCount(4);
            content.SelectToken("structuredQuery.select.fields[0]").Value <JObject>().Should().ContainKey("fieldPath");
            content.SelectToken("structuredQuery.select.fields[0].fieldPath").Value <string>().Should().Be("lat");
            content.SelectToken("structuredQuery.select.fields[1]").Value <JObject>().Should().ContainKey("fieldPath");
            content.SelectToken("structuredQuery.select.fields[1].fieldPath").Value <string>().Should().Be("lng");
            content.SelectToken("structuredQuery.select.fields[2]").Value <JObject>().Should().ContainKey("fieldPath");
            content.SelectToken("structuredQuery.select.fields[2].fieldPath").Value <string>().Should().Be("remark");
            content.SelectToken("structuredQuery.select.fields[3]").Value <JObject>().Should().ContainKey("fieldPath");
            content.SelectToken("structuredQuery.select.fields[3].fieldPath").Value <string>().Should().Be("email");
            content.SelectToken("structuredQuery").Value <JObject>().Should().ContainKey("from");
            content.SelectToken("structuredQuery.from").Value <JArray>().Should().HaveCount(1);
            content.SelectToken("structuredQuery.from[0]").Value <JObject>().Should().ContainKey("collectionId");
            content.SelectToken("structuredQuery.from[0].collectionId").Value <string>().Should().Be("remarks");
            content.SelectToken("structuredQuery").Value <JObject>().Should().ContainKey("orderBy");
            content.SelectToken("structuredQuery.orderBy").Value <JArray>().Should().HaveCount(1);
            content.SelectToken("structuredQuery.orderBy[0]").Value <JObject>().Should().ContainKey("field");
            content.SelectToken("structuredQuery.orderBy[0].field").Value <JObject>().Should().ContainKey("fieldPath");
            content.SelectToken("structuredQuery.orderBy[0].field.fieldPath").Value <string>().Should().Be("email");

            header.Should().ContainKey("Authorization");
            header["Authorization"].Should().Be(_requestAuthorisation);
        }