Skip to content

Latest commit

 

History

History
525 lines (316 loc) · 30.7 KB

README.md

File metadata and controls

525 lines (316 loc) · 30.7 KB

Back-End Technologies Basics

Welcome to my repository for the 'Back-End Technologies Basics' course in QA Engineering at SoftUni. Here, I will be sharing my exercises.

Folder:

Section 1: Data Formats - JSON, XML, and YAML (Lesson 1)

Exercise 1:

  • Added initial product data in JSON format for practical exercises.
  • Products include details such as name, price, description, and keywords.

Exercise 2:

  • Introduced city data in XML format representing information about various cities.
  • Includes city name, country, population, and notable landmarks.

Exercise 3:

  • Added country data in YAML format, providing information on countries, capitals, populations, and spoken languages.

These exercises are part of the "Data Formats" lesson, exploring JSON, XML, and YAML in the context of Back-End Technologies Basics. The datasets serve as valuable resources for hands-on learning and practical application of data formats in backend development.

Section 2: Exercises: Data Formats (Lesson 2)

Exercise Summary:

In this exercise set, we explored various data formats, including JSON, XML, and YAML. The exercises involved creating and parsing data structures in each format to reinforce understanding and practical application. Here's a brief overview:

JSON Exercise 1:

  • Included book data in JSON format.
  • Applied for practical exercises on nested JSON structures and data representation.

JSON Exercise 2:

  • Added student and course data in JSON format.
  • Utilized for exploring complex JSON structures and relationships.

YAML Exercise 3:

  • Integrated order data in YAML format.
  • Explored YAML data processing and understanding complex data structures.

YAML Exercise 4:

  • Introduced reservation data in YAML format.
  • Used for hands-on exercises focusing on YAML structures and nested data.

XML Exercise 5:

  • Added device data in XML format.
  • Utilized for exploring XML parsing and processing techniques.

XML Exercise 6:

  • Integrated vehicle data in XML format.
  • Applied for practical exercises on XML parsing and transformation.

How to Use:

  • The associated C# programs demonstrate parsing and processing of data in each format.
  • Choose the desired data format exercise by running the program and following on-screen prompts.

Section 3: JavaScript Basics (Lesson 3)

Overview:

This section covers fundamental JavaScript concepts and practices, providing a solid foundation for beginners. The exercises focus on practical scenarios, allowing learners to apply their knowledge and enhance problem-solving skills.

Exercise 1: Simple Multiplication

  • Implemented a basic JavaScript function to multiply a given number by 2. This exercise serves as an introduction to writing simple functions.

Exercise 2: Display Information

  • Created a function to display information about a person, including their name, age, and grade. This exercise emphasizes string interpolation and formatting in JavaScript.

Exercise 3: Check for Excellence

  • Implemented a conditional function to check if a given number is excellent. This exercise introduces basic if-else statements.

Exercise 4: Convert Month Number to Name

  • Developed a function to convert a numerical month representation into its corresponding name. This exercise showcases the usage of switch statements.

Exercise 5: Arithmetic Operations

  • Introduced a function to perform various arithmetic operations based on user input. This exercise highlights the practical application of switch statements in JavaScript.

Exercise 6: Find the Largest Number

  • Implemented a function to find the largest among three numbers using Math.max. This exercise emphasizes the usage of built-in functions in JavaScript.

Exercise 7: Calculate Ticket Price

  • Created a function to calculate ticket prices based on age and type of day. This exercise demonstrates nested conditional statements.

Exercise 8: Calculate Circle Area

  • Introduced a function to calculate the area of a circle, given the radius. This exercise emphasizes handling different data types using typeof.

Exercise 9: Print Numbers

  • Implemented a loop to print numbers from 1 to 5. This exercise reinforces the fundamental concept of loops in JavaScript.

Exercise 10: Print Numbers in Reverse

  • Developed a function to print numbers in reverse order within a specified range. This exercise provides hands-on experience with loops and conditional statements.

Section 4: JavaScript - Exercises (Lesson 4)

Overview:

This section delves deeper into JavaScript, presenting a series of exercises that cover various aspects of the language. From conditional statements and loops to functions and logical operations.

Exercise 1: Age Group Classifier

  • Implemented a function to classify individuals into different age groups based on predefined ranges. This exercise focuses on using conditional statements effectively.

Exercise 2: Group Cost Calculator

  • Created a function to calculate the total cost for different groups attending events on specific days. This exercise involves nested conditionals and arithmetic operations.

Exercise 3: Leap Year Checker

  • Developed a function to determine if a given year is a leap year. This exercise reinforces logical operators and conditional statements.

Exercise 4: Number Range Sum

  • Implemented a function to calculate the sum of numbers within a specified range. This exercise emphasizes loop structures and basic arithmetic operations.

Exercise 5: Multiplication Table Generator

  • Developed a function to generate and display the multiplication table for a given number. This exercise reinforces the use of loops for repetitive tasks.

Exercise 6: Digit Sum Calculator

  • Implemented a function to calculate the sum of digits in a given number. This exercise introduces while loops and basic arithmetic operations.

Exercise 7: Character Concatenation

  • Created a function to concatenate three characters and display the resulting string. This exercise emphasizes string manipulation in JavaScript.

Exercise 8: Reverse Characters

  • Implemented a function to reverse the order of three characters. This exercise provides practice with string manipulation and array operations.

Exercise 9: Fruit Purchase Calculator

  • Developed a function to calculate the total cost of purchasing a specified amount of fruit. This exercise involves basic arithmetic operations and string formatting.

Exercise 10: Identical Digits Checker

  • Implemented a function to check if all digits in a given number are identical. This exercise involves using loops and conditional statements for digit comparison.

Exercise 11: Speed Limit Checker

  • Created a function to check if a vehicle is within the speed limit based on the speed zone. This exercise demonstrates the use of if-else statements and logical operators.

Exercise 12: Culinary Operations Simulator

  • Implemented a function simulating a series of cooking operations on a numerical input. This exercise emphasizes function composition and conditional logic in a culinary context.

Section 5: JavaScript Fundamentals (Lesson 5)

Overview:

This section focuses on fundamental JavaScript concepts, covering exercises that explore arrays, loops, conditionals, and basic data manipulation.

Exercise 1: Array Element Sum

  • Developed a function to calculate the sum of the first and last elements of an array. This exercise introduces basic array manipulation in JavaScript.

Exercise 2: Array Reversal

  • Implemented a function to reverse the order of elements in an array. This exercise reinforces array manipulation skills, particularly using loops.

Exercise 3: Even and Odd Sum

  • Created a function to calculate the difference between the sums of even and odd numbers in an array. This exercise involves loop iteration and conditional statements.

Exercise 4: Substring Extractor

  • Developed a function to extract a substring from a given text based on a specified start index and count. This exercise reinforces string manipulation in JavaScript.

Exercise 5: Word Censorship

  • Implemented a function to censor a banned word in a text by replacing it with asterisks. This exercise introduces string replacement and loop-based string manipulation.

Exercise 6: Word Counter

  • Created a function to count the occurrences of a specific word in a text. This exercise involves splitting a text into words and counting using loops.

Exercise 7: Grade Classifier

  • Implemented a function to classify grades into different categories. This exercise introduces conditional statements based on grade ranges.

Exercise 8: Power Calculator

  • Developed a function to calculate the power of a number. This exercise emphasizes using the Math.pow function for mathematical operations.

Exercise 9: String Repeater

  • Implemented a function to repeat a given string a specified number of times. This exercise involves loop iteration for string concatenation.

Exercise 10: Product Price Calculator

  • Created a function to calculate the total price of a product based on its type and quantity. This exercise involves switch statements for product-specific pricing.

Exercise 11: Person Object Creator

  • Developed a function to create a person object with specified attributes. This exercise introduces object creation and initialization.

Exercise 12: Object Property Printer

  • Implemented a function to print the properties of an object. This exercise reinforces object iteration and property access.

Exercise 13: Unique Names and Phone Numbers

  • Developed a function to extract and print unique names and phone numbers from an array of strings. This exercise emphasizes object creation and string manipulation.

Section 6: JavaScript Fundamentals Exercises (Lesson 6)

Overview:

This section delves deeper into JavaScript fundamentals, covering exercises that explore array manipulation, string operations, and object handling. The exercises provide hands-on experience in practical scenarios, reinforcing core concepts.

Exercise 1: Array Rotation

  • Developed a function to rotate the elements of an array a specified number of times. This exercise focuses on array manipulation and rotation.

Exercise 2: Array Stepper

  • Implemented a function to select elements from an array with a specified step. This exercise reinforces array manipulation skills, particularly using loops.

Exercise 3: Alphabetical Order

  • Created a function to sort an array of strings alphabetically. This exercise involves the use of the sort method and string comparison.

Exercise 4: Min-Max Array

  • Developed a function to rearrange an array, placing the smallest and largest elements alternatively. This exercise reinforces array sorting and manipulation.

Exercise 5: Word Replacement

  • Implemented a function to replace specific words in a text with corresponding words from another list. This exercise introduces string replacement and array manipulation.

Exercise 6: Word Finder

  • Created a function to check if a specific word exists in a given text. This exercise involves string manipulation and conditional statements.

Exercise 7: Smallest Number

  • Implemented a function to find the smallest number among three given numbers. This exercise emphasizes the use of conditional statements and mathematical operations.

Exercise 8: Arithmetic Operations

  • Developed a function to perform arithmetic operations based on user input. This exercise highlights practical applications of switch statements in JavaScript.

Exercise 9: String Repeater

  • Implemented a function to repeat a given string a specified number of times. This exercise involves loop iteration for string concatenation.

Exercise 10: Password Validator

  • Developed a function to validate a password based on specified criteria. This exercise introduces regular expressions and error handling.

Exercise 11: Employee Data Processor

  • Implemented a function to process an array of employee names, generating additional data. This exercise emphasizes object creation and array iteration.

Exercise 12: Geographical Data Formatter

  • Developed a function to format geographical data into objects with specific attributes. This exercise reinforces object creation and property initialization.

Exercise 13: Stock Inventory Manager

  • Created a function to manage stock levels based on current and ordered stock data. This exercise involves object manipulation and iteration.

Exercise 14: Movie Database Manager

  • Implemented a function to manage a movie database, processing commands to add details to movies. This exercise showcases object manipulation and filtering.

Exercise 15: RPG Heroes Data Processor

  • Developed a function to process RPG heroes' data, sorting and displaying relevant information. This exercise emphasizes object creation, sorting, and output formatting.

Exercise 16: Odd Word Occurrence Finder

  • Implemented a function to find and return words with odd occurrences in a given text. This exercise involves string manipulation, word counting, and object handling.

Exercise 17: Parking Lot Manager

  • Developed a function to manage a parking lot, processing data for incoming and outgoing cars. This exercise demonstrates the use of a Set for efficient data management and sorting.

Section 7: Unit Testing with JavaScript (Lesson 7)

Overview:

This section focuses on the fundamentals of unit testing in JavaScript. It covers exercises that involve writing unit tests for various functions to ensure their correctness and reliability.

Exercise 1: Sum Function

  • Implemented a sum function that calculates the sum of an array of numbers.
  • Created unit tests using Chai and Mocha to validate the function's behavior with different input scenarios.

Exercise 2: Symmetry Checker

  • Developed an isSymmetric function to check if an array is symmetric.
  • Created unit tests to verify the function's correctness with symmetric and non-symmetric arrays, as well as edge cases.

Exercise 3: RGB to Hex Color Converter

  • Implemented an rgbToHexColor function to convert RGB values to hexadecimal color codes.
  • Created comprehensive unit tests to cover various scenarios, including invalid input values and correct conversions.

Exercise 4: Calculator Factory

  • Implemented a createCalculator function that returns a calculator object with add, subtract, and get methods.
  • Developed unit tests to ensure the calculator behaves correctly with various sequences of addition and subtraction operations.

Section 8: Unit Testing with JavaScript - Exercises (Lesson 8)

Overview:

This section focuses on unit testing principles in JavaScript, emphasizing the importance of testing functions for correctness and reliability. The exercises cover writing unit tests for different functions to ensure their robustness.

Exercise 1: Odd or Even Checker

  • Implemented an isOddOrEven function to determine whether the length of a given string is odd or even. Created unit tests using Chai and Mocha to validate the function's behavior with various input types, including non-strings and empty strings.

Exercise 2: Character Lookup

  • Developed a lookupChar function to retrieve a character at a specified index from a given string. Designed unit tests to ensure the function handles different scenarios, such as invalid input types, incorrect indices, and correct character retrieval.

Exercise 3: Math Enforcer

  • Created a mathEnforcer object with methods for adding five, subtracting ten, and calculating the sum of two numbers. Implemented thorough unit tests to validate the object's behavior with different input types, including strings and various numeric values.

Exercise 4: Array Analyzer

  • Implemented an analyzeArray function to calculate the minimum, maximum, and length of a numeric array. Crafted unit tests to ensure the function handles arrays with different elements, empty arrays, and arrays with identical elements correctly.

Note: Each exercise includes comprehensive unit tests using Chai and Mocha to cover a wide range of scenarios, ensuring the reliability and correctness of the implemented functions.

Section 9: Databases - SQL and NoSQL (Lesson 9)

Overview:

This section provided a comprehensive overview of databases, focusing on SQL Server Management Studio (SSMS) for SQL databases and MongoDB for NoSQL databases. Participants gained hands-on experience in executing SQL queries, covering essential CRUD operations (Create, Read, Update, Delete). Additionally, practical exercises involved working with MongoDB, including the insertion of JSON files and performing operations using MongoDB Compass. This laid the foundation for understanding fundamental database concepts and operations in both SQL and NoSQL environments.

Section 10: Integration Testing (Lesson 10)

Overview:

This section delves into integration testing for the TownsApplication project, focusing on validating the functionality of the TownController class. Integration tests have been created to ensure the correctness and reliability of key operations such as adding, updating, deleting towns, handling invalid input, preventing duplicates, and listing all towns.

Project Structure:

  • Main File (Program.cs):

    • Implements the console-based Town Management System.
    • Utilizes the TownController for town-related operations.
  • DbContext (TownDbContext.cs):

    • Defines the TownDbContext class, responsible for interacting with the in-memory database.
  • Model (Town.cs):

    • Represents the Town entity with properties like Id, Name, and Population.
  • Controller (TownController.cs):

    • Manages town-related operations, including adding, updating, deleting, listing, and resetting the database.
    • Implements validation for town names and populations.

Integration Tests (TownControllerIntegrationTests.cs):

  • AddTown_ValidInput_ShouldAddTown:

    • Tests the successful addition of a town with valid inputs.
  • AddTown_InvalidName_ShouldThrowArgumentException:

    • Ensures that AddTown throws an ArgumentException for invalid town names.
  • AddTown_InvalidPopulation_ShouldThrowArgumentException:

    • Validates that AddTown handles invalid population values and throws the expected exception.
  • AddTown_DuplicateTownName_DoesNotAddDuplicateTown:

    • Verifies that AddTown does not add a duplicate town with the same name.
  • UpdateTown_ShouldUpdatePopulation:

    • Checks if the UpdateTown method correctly updates the population of a town.
  • DeleteTown_ShouldDeleteTown:

    • Tests the deletion of a town and ensures it is removed from the database.
  • ListTowns_ShouldReturnTowns:

    • Validates that the ListTowns method correctly returns a list of all towns in the database.

Section 11: Integration Testing - Exercises - Part1 (Lesson 11)

This section covers exercises related to integration testing in the context of the LibroConsoleAPI project. Integration tests are crucial for verifying the interactions between various components of the application and ensuring that they work together as expected.

Content:

  1. Integration Test Files:

    • AddBookMethodTests.cs: Contains tests for adding books to the database, covering scenarios with valid and invalid input data.
    • DeleteBookMethodTests.cs: Focuses on testing the deletion of books from the database, including cases with valid and invalid ISBNs.
    • GetAllBooksMethodTests.cs: Tests the retrieval of all books from the database, handling scenarios where books exist and where none are found.
    • GetSpecificAsyncMethodTests.cs: Covers tests for retrieving a specific book from the database based on its ISBN, handling cases with valid and invalid ISBNs.
    • SearchByTitleMethodTests.cs: Tests the functionality of searching for books by their titles, considering scenarios with valid and invalid title fragments.
    • UpdateBookMethodTests.cs: Validates the functionality of updating book details in the database, including cases with valid and invalid input data.
  2. Purpose:

    • Validate the behavior of the BookManager class and its interaction with the database.
    • Ensure that CRUD (Create, Read, Update, Delete) operations on books function correctly.
    • Cover edge cases and handle invalid inputs to maintain the integrity and reliability of the application.
  3. Technologies Used:

    • C#
    • xUnit testing framework
    • nUnit testing framework
    • Entity Framework Core for database operations

Section 12: Integration Testing - Exercises - Part 2 (Lesson 12)

In this section, we continued our exploration of integration testing by delving deeper into testing the integration between various components of our application. We focused on testing the interactions between different layers, such as controllers, services, repositories, and the database.

Contents:

  1. XUnit Integration Tests:

    • Implemented integration tests using XUnit framework.
    • Covered CRUD operations for managing movies in the library.
    • Ensured proper handling of valid and invalid movie data.
    • Verified functionality for adding, deleting, updating, and retrieving movies.
    • Utilized XUnit's Fact and Theory attributes for different test scenarios.
    • Checked for expected exceptions and handled edge cases appropriately.
  2. NUnit Integration Tests:

    • Developed integration tests using NUnit framework.
    • Covered similar functionalities as XUnit tests, focusing on CRUD operations for managing movies.
    • Ensured proper handling of valid and invalid movie data.
    • Verified functionality for adding, deleting, updating, and retrieving movies.
    • Utilized NUnit's SetUp, TearDown, and OneTimeSetUp, OneTimeTearDown attributes for test setup and teardown operations.

These exercises provided hands-on experience in thoroughly testing the integration between various components of our application, ensuring robustness and reliability.

Section 13: Unit Testing with Mocking (Lesson 13)

In Section 13, "Unit Testing with Mocking," you'll delve into the essential practice of unit testing with mocking techniques. Unit testing is a crucial aspect of software development, enabling you to validate individual units of code in isolation to ensure they function as expected. Mocking, on the other hand, allows you to simulate dependencies of the unit under test, providing controlled environments for testing without reliance on external resources.

Exercise Summaries:

  1. Exercise 1: Greeting Provider Unit Testing

    • Objective: The objective of this exercise is to test the GetGreeting method of the GreetingProvider class, which returns a greeting message based on the current time of day.
    • Techniques Learned:
      • Mocking the ITimeProvider interface using Moq to simulate different time scenarios.
      • Writing unit tests to verify the behavior of the GetGreeting method under various time conditions.
    • Key Concepts Covered:
      • Using setup methods in Moq to define the behavior of mock objects.
      • Employing assertions to verify the correctness of method outputs.
      • Testing edge cases and boundary conditions to ensure comprehensive coverage.
  2. Exercise 2: ItemRepository Unit Testing

    • Objective: This exercise focuses on testing the methods of the ItemService class, which interacts with an ItemRepository to perform CRUD operations on items.
    • Techniques Learned:
      • Mocking the IItemRepository interface to isolate the ItemService from the actual database.
      • Writing unit tests to cover different scenarios such as adding, updating, deleting items, and validating input.
    • Key Concepts Covered:
      • Using Moq to mock repository interactions and simulate database behavior.
      • Testing exception handling and error conditions.
      • Validating input parameters and ensuring method correctness under various conditions.

Section 14: RESTful API Testing - Exercises (Lesson 14)

In Section 14, "RESTful API Testing," we focus on ensuring the reliability and functionality of our RESTful API endpoints. Through comprehensive testing strategies, we validate the behavior of our API methods, covering scenarios such as adding, retrieving, updating, and deleting resources.

Key Topics Covered:

  • Writing integration tests for API endpoints using NUnit.
  • Mimicking database behavior with an in-memory database for controlled testing environments.
  • Applying the Arrange-Act-Assert pattern to structure test cases effectively.
  • Testing various scenarios, including successful operations, error handling, and edge cases.
  • Verifying the correctness of API responses and ensuring proper data manipulation.

Exercises Included:

  1. EventService Integration Testing: Integration tests are created to validate the functionality of the EventService class, covering methods for managing events in our application. These tests ensure that events can be added, retrieved, updated, and deleted correctly, while also checking for error handling and edge cases.

  2. Comprehensive Test Suite: A comprehensive suite of tests is developed to assess different aspects of the API, including adding events, retrieving event details, joining and leaving events, updating events, and checking user participation. These tests help maintain the reliability and stability of the API functionality across various scenarios.

By mastering RESTful API testing techniques, we ensure that our API endpoints perform as expected, providing a robust foundation for our application's backend functionality.

Section 15: Code Coverage in JS and C# (Lesson 15)

In Lesson 15, we explored the concept of code coverage and its importance in ensuring the reliability and effectiveness of our codebase. We delved into techniques for measuring code coverage in both JavaScript (JS) and C# environments, leveraging tools such as NYC for JS and built-in features for C#.

Key Concepts Covered:

  • Code Coverage Fundamentals: Understanding what code coverage is and why it's crucial for assessing the quality of our code.
  • JS Code Coverage with NYC: Exploring how to measure code coverage in JavaScript using the NYC (istanbul) tool, analyzing our test suite's effectiveness in covering our codebase.
  • C# Code Coverage: Implementing code coverage analysis in C# projects, utilizing built-in features and tools to ensure comprehensive testing coverage.

Highlights:

  • JavaScript Coverage: We learned how to integrate NYC into our JavaScript projects, gaining insights into the percentage of code covered by our tests and identifying areas for improvement.
  • C# Coverage: Exploring code coverage within C# projects, we enhanced our testing suite to achieve higher coverage percentages, improving the overall reliability and robustness of our applications.

Why Code Coverage Matters:

Code coverage serves as a critical metric in software development, indicating the proportion of our codebase that is exercised by tests. By striving for high code coverage percentages, we can increase confidence in our code's correctness, identify potential bugs early in the development cycle, and facilitate more effective maintenance and refactoring efforts.

Section 16: Mutation Testing (Lesson 16)

In Lesson 16, we delved into the realm of Mutation Testing, a powerful technique used to assess the effectiveness of our unit tests by introducing small changes, or mutations, into the source code and then re-running the tests to determine if any mutations cause the tests to fail. This process helps evaluate the robustness of our test suite by identifying areas where our tests may be insufficient in detecting faults or changes in the codebase.

Key Concepts Covered:

  • Understanding Mutation Testing and its significance in software testing.
  • Implementing Mutation Testing using tools like Stryker.
  • Analyzing mutation reports to identify areas for improving test coverage and test effectiveness.
  • Enhancing the reliability of unit tests by incorporating mutation testing into the testing workflow.

Through practical exercises and examples, we gained hands-on experience in applying mutation testing techniques to real-world codebases, allowing us to refine our testing strategies and bolster the overall quality and reliability of our software projects.