Skip to Content
Serverless computing in Azure with .NET
book

Serverless computing in Azure with .NET

by Sasha Rosenbaum
August 2017
Intermediate to advanced
468 pages
12h 5m
English
Packt Publishing
Content preview from Serverless computing in Azure with .NET

Unit test examples

In the following unit test, we are looking at a use case in which a valid input text string is submitted to the ScoreTextSentiment method, and the Text Analytics API returns a valid output with a double text sentiment score. The ScoreTextSentiment method is then expected to correctly parse the API output, and return the expected double score.

To arrange the test case, we create an expected score, and a valid input string. We then mock HttpMessageHandler, and set up the SendAsync method to return HttpStatusCode.OK (200), and a correctly formatted JSON output with the expected text sentiment score. Notice that the inputText string, in itself, bears no significance as long as it is a valid string (so that it does not cause ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Azure Serverless Computing

Mastering Azure Serverless Computing

Lorenzo Barbieri, Massimo Bonanni
Implementing Azure: Putting Modern DevOps to Use

Implementing Azure: Putting Modern DevOps to Use

Florian Klaffenbach, Oliver Michalski, Markus Klein, Mohamed Wali

Publisher Resources

ISBN: 9781787288393Supplemental Content