public async Task ShouldReturnAllSentiments() { await AddAsync(new Sentiment { Word = "nice", SentimentScore = 0.4f }); await AddAsync(new Sentiment { Word = "excellent", SentimentScore = 0.8f }); await AddAsync(new Sentiment { Word = "modest", SentimentScore = 0 }); var query = new GetAllSentimentsQuery(); var result = await SendAsync(query); result.Should().NotBeNull(); result.Succeeded.Should().BeTrue(); result.Data.Count.Should().Be(3); }
public async Task <ServiceResult <List <SentimentDto> > > Handle(GetAllSentimentsQuery request, CancellationToken cancellationToken) { List <SentimentDto> list = await _context.Sentiments .ProjectToType <SentimentDto>(_mapper.Config) .ToListAsync(cancellationToken); return(list.Count > 0 ? ServiceResult.Success(list) : ServiceResult.Failed <List <SentimentDto> >(ServiceError.NotFount)); }
public async Task ShouldReturnTheCorrectSentiment() { await AddAsync(new Sentiment { Word = "nice", SentimentScore = 0.4f }); var query = new GetAllSentimentsQuery(); var result = await SendAsync(query); result.Should().NotBeNull(); result.Succeeded.Should().BeTrue(); result.Data.Count.Should().Be(1); result.Data[0].Word.Should().Be("nice"); result.Data[0].SentimentScore.Should().Be(0.4f); }