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); } }
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)); }
public async Task <IHttpActionResult> GetTopic(int id) { var result = await _repository.Get(id).ConfigureAwait(false); return(result == null ? (IHttpActionResult)NotFound() : Ok(result)); }
public Topics Get(Int64 ixTopic) => _topicsRepository.Get(ixTopic);