You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
14 Hrs
0 Min
47 Seg

Herramientas y c贸digo base

5/19
Resources

How to download and configure the project?

To start working on your own unit tests, you must first download the base project from GitHub, a crucial step for developers looking to delve into the creation of string manipulation libraries in .NET. In the GitHub repository, provided in the course resources, you'll find two branches: master and codebase. Both contain the same clean project to implement tests, but without examples or pre-existing tests.

How to download the project?

  1. Clone the repository: If you want to work directly from a version-controlled environment, use git clone to get the repository on your local machine.
  2. Download as a .zip file: For those who prefer to handle files manually, there is the option to download the project as a compressed file.
  3. Create a new repository: Regardless of the download method, it is recommended to create a new repository on your personal GitHub to store your progress and customizations.

How to structure the project in Visual Studio?

With the project already downloaded, the next step is to open it in Visual Studio, where you can explore its structure. The project is known as "StringManipulation" and contains the main class "StringOperation", which in short, acts as a library of utilities for manipulating strings.

What functions does the StringOperation library include?

  • Concatenate: Allows to join several strings into one.
  • Reverse: Reverses the order of characters in a string.
  • GetStringLength: Returns the length of a string.
  • RemoveWhiteSpaces: Removes whitespaces in a string.
  • TruncateString: Truncates a string by the maximum number of characters specified.
  • Palindrome detection: Checks if a word is a palindrome.
  • Occurrences of a character: Counts how many times a specific character appears in a string.
  • Pluralize: Converts a singular word to its plural form.
  • QuantityInWords: Converts numbers within a sentence to words.
  • Roman numerals: Converts Roman numerals to integers.
  • Read String from file: Allows to load the content of a file as a string.

Examples of use in the Program class

The "Program" class allows executing and testing the operation of the library functions. It is not only a utility for testing, but also provides a point of interaction for the user:

  • TruncateString: executes the function by entering a string and a maximum number of characters. For example, entering "Hello everyone from Platzi" with a maximum of 6 characters returns "Hello and".
  • Pluralize Word: Transforms words such as "Card" and "City", displaying their plural form as "Cards" and "Cities", respectively.
  • Roman numerals: Converts Roman numerals such as "VI" to the number 6.

How to perform unit tests with XUnit?

The next step is to test these functions by creating our own unit tests. XUnit is a popular and easy-to-use testing framework in .NET:

  1. Identify test scenarios: Develop different test cases for each function, making sure to cover the broad spectrum of possibilities and verify that the functions behave properly.
  2. Build and run: Use XUnit to write, run and validate your test results.

Encourage students to explore and strengthen their programming skills by practicing creating tests under various conditions. This will give you an excellent opportunity to discover how each feature can be integrated into larger applications, extending functionality and bringing improvements to a project. Go ahead, continue your learning, testing and development has never been so exciting!

Contributions 1

Questions 2

Sort by:

Want to see more contributions, questions and answers from the community?

A mi me daba error con al momento de copilar ;

Severity Code Description Project File Line Suppression State
Error NETSDK1045 The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. StringManipulation C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets 144

Ajuste este Tag
<TargetFramework>.NETCoreApp,Version=v6.0</TargetFramework>