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");
        }
Beispiel #2
0
 public async Task UpdateRemark(string remarkId, UpdateRemarkRequest request)
 {
     await _repository.UpdateRemark(remarkId, new UpdatableRemarkDetails
     {
         Remark = request.Remark
     });
 }
        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);
        }