コード例 #1
0
        public async void GetRemarks_Should_Return_Correctly()
        {
            var expected = new [] { new RemarkDetails() };

            _repository.GetRemarks().Returns(expected);

            var actual = await _service.GetRemarks();

            actual.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
        public async Task <IEnumerable <RemarkDetails> > GetRemarks(string filter = null)
        {
            var list = await _repository.GetRemarks();

            return(string.IsNullOrWhiteSpace(filter)
                ? list
                : list.Where(item =>
                             item.Email.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
                             item.Remark.Contains(filter, StringComparison.OrdinalIgnoreCase)));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public JsonResult GetRemarks()
        {
            var remarks = _rep.GetRemarks();

            return(Json(new { data = remarks }));
        }