Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Practical Test-Driven Development using C# 7

You're reading from   Practical Test-Driven Development using C# 7 Unleash the power of TDD by implementing real world examples under .NET environment and JavaScript

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher
ISBN-13 9781788398787
Length 442 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Callaway Callaway
Author Profile Icon Callaway
Callaway
 Hunt Hunt
Author Profile Icon Hunt
Hunt
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Title Page
Packt Upsell
Foreword
Contributors
Preface
1. Why TDD is Important FREE CHAPTER 2. Setting Up the .NET Test Environment 3. Setting Up a JavaScript Environment 4. What to Know Before Getting Started 5. Tabula Rasa – Approaching an Application with TDD in Mind 6. Approaching the Problem 7. Test-Driving C# Applications 8. Abstract Away Problems 9. Testing JavaScript Applications 10. Exploring Integrations 11. Changes in Requirements 12. The Legacy Problem 13. Unraveling a Mess 14. A Better Foot Forward 1. Other Books You May Enjoy Index

Speaker details


Next up we come to the speaker details. We've chosen to continue in the back-end application as we'll tie the entire program together in up coming chapters.  

As stated earlier, this is where the real value is delivered for the first set of requirements. User groups and conference organizers will be able to contact a speaker using the information provided in the details view.

API

To return the details of an individual speaker, a new endpoint is needed. A new method Get is required which will take an integer ID and return a SpeakerDetail ViewModel.

API tests

To get started, add a new test class named Get. Now, add a test to check that the Get method exists.

[Fact]
public void ItExists()
{
  // Arrange
  var speakerServiceMock = new Mock<ISpeakerService>();
  var controller = new SpeakerController(speakerServiceMock.Object);

  // Act
  var result = controller.Get();
}

Make this test pass by adding a Get method to the SpeakerController. Note that, in the following example, the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images