public async void UpdateRemark_Should_Call_IApiRequestProvider_CreatePatchRequest()
        {
            JObject content = null;
            Dictionary <string, string> header = null;
            Dictionary <string, string> query  = null;

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

            var remarkId = "remarkId";
            var updates  = new UpdatableRemarkDetails
            {
                Remark = "remarks"
            };
            await _repository.UpdateRemark(remarkId, updates);

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

            content.Should().ContainKey("fields");
            content.SelectToken("fields").Value <JObject>().Should().ContainKey("remark");
            content.SelectToken("fields.remark").Value <JObject>().Should().ContainKey("stringValue");
            content.SelectToken("fields.remark.stringValue").Value <string>().Should().Be(updates.Remark);

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

            query.Should().ContainKey("key");
            query["key"].Should().Be(_firebaseApiKey);
            query["currentDocument.exists"].Should().Be("true");
            query["updateMask.fieldPaths"].Should().Be("remark");
        }
 private JObject CreateUpdateRemarkRequest(UpdatableRemarkDetails updates)
 {
     return(new JObject
     {
         ["fields"] = new JObject
         {
             ["remark"] = new JObject {
                 ["stringValue"] = updates.Remark
             }
         }
     });
 }
        public async Task UpdateRemark(string remarkId, UpdatableRemarkDetails updates)
        {
            var url     = $"{_endpoint}/remarks/{remarkId}";
            var content = CreateUpdateRemarkRequest(updates);

            var updateQuery = new Dictionary <string, string>(_defaultQuery);

            updateQuery.Add("currentDocument.exists", "true");
            updateQuery.Add("updateMask.fieldPaths", "remark");

            var request = _requestProvider.CreatePatchRequest(url, content, headers: _defaultHeader, queries: updateQuery);
            await _apiClient.Send <object>(request);
        }
        public async void UpdateRemark_Should_Call_IRemarksRepository_UpdateRemark()
        {
            var remarkId = "remarkId";
            var request  = new UpdateRemarkRequest
            {
                Remark = "remarks"
            };

            UpdatableRemarkDetails arg = null;
            await _repository.UpdateRemark(Arg.Any <string>(), Arg.Do <UpdatableRemarkDetails>(a => arg = a));

            await _service.UpdateRemark(remarkId, request);

            await _repository.Received(1).UpdateRemark(remarkId, Arg.Any <UpdatableRemarkDetails>());

            arg.Remark.Should().Be(request.Remark);
        }