コード例 #1
0
        public async void GetCurrentTopic()
        {
            var expected = new TopicModel
            {
                Date        = new DateTime(2017, 02, 12),
                Description = "topic 1.......",
                Keyword     = "key1",
                Title       = "Topic 1"
            };

            _topicsRepositoryMock
            .Get(Arg.Is <int>(1))
            .Returns(expected);

            // act
            using (var client = _server.HttpClient)
            {
                var response = await client.GetAsync("v1/topics/1");

                // assert
                response.IsSuccessStatusCode.Should().BeTrue();
                var message = await response.Content.ReadAsStringAsync();

                var actual = JsonConvert.DeserializeObject <TopicModel>(message);

                actual.ShouldBeEquivalentTo(expected);
            }
        }
コード例 #2
0
        public async Task <IActionResult> Get(Guid id)
        {
            var entity = await repository.Get(id);

            var dto = new TopicForRetrieval
            {
                Id          = entity.Id,
                Title       = entity.Title,
                Description = entity.Description,
                CreatedBy   = entity.CreatedBy.Username,
                CreatedById = entity.CreatedById
            };

            return(Ok(dto));
        }
コード例 #3
0
        public async Task <IHttpActionResult> GetTopic(int id)
        {
            var result = await _repository.Get(id).ConfigureAwait(false);

            return(result == null
                ? (IHttpActionResult)NotFound()
                : Ok(result));
        }
コード例 #4
0
 public Topics Get(Int64 ixTopic) => _topicsRepository.Get(ixTopic);