Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do unit testing in C# according to the following sample output: Sample Output Format Testing method GetPayment(decimal, int, decimal) Test 1 Expected: The argument

Please do unit testing in C# according to the following sample output:

Sample Output Format

Testing method GetPayment(decimal, int, decimal) Test 1 Expected: The argument cannot be less than 0. Parameter name: rate Actual: The argument cannot be less than 0. Parameter name: rate Test 2 Expected: 526.23 Actual: 526.23 

DO NOT use keyboard input. Hard code all test values.

If a method has more than one outcome, you will require a test for each outcome. Ensure you indicate the test number for each test.

Avoid creating additional methods to reduce repetition in your test application. It is expected that some lines of code will be duplicated.

Need to solve Program.

Program

Create a new Console App (.NET Framework) Project. Name the project LastName.FirstName.RRCAGTests, where FirstName and LastName correspond to your first and last names.

Name the Visual Studio Solution Assignment2FirstNameLastName, where FirstName and LastName correspond to your first and last names.

Examples

If your name is Dallas Page, the project and solution would be named:

Project: Page.Dallas.RRCAGTests

Solution: Assignment2DallasPage

Copy the LastName.FirstName.Business.dll from the other Visual Studio solution (RRCAGLibraryFirstNameLastName - created above) and put it in the Debug/bin directory of your Console Application. Add a reference to the library (LastName.FirstName.Business.dll) in order to access the library classes.

Program Class

The Program class is generated when you created the Console App (.NET Framework) Project template. Ensure the Program class is in the LastName.FirstName.RRCAGTests namespace.

Program Requirements

Your program will include implementation to test the following members of the Financial class:

+ GetPayment(decimal, int, decimal) : decimal

For each method (unit) being tested, ensure your client program provides output clearly describing the method being tested, along with the expected and actual result.

Each unit test will be written in its own method. Not writing your unit tests in methods will not earn you credit on the assignment.

Each unit test method will test one outcome only.

Each unit test method will be named using the standard outlined in the course material.

When a test fails (actual does not match the expected), correct the method code, then re-test. Keep in mind that a poorly written test can produce inaccurate test results. If a test fails, ensure you have written the test correctly before modifying your unit code.

Output Requirement

For each method (unit) being tested, output the method signature.

For each test, output the following:

Test number

Outcome description

Expected result

Actual result

Leave one blank line between each test.

Sample Output Format

Testing method GetPayment(decimal, int, decimal) Test 1 Expected: The argument cannot be less than 0. Parameter name: rate Actual: The argument cannot be less than 0. Parameter name: rate Test 2 Expected: 526.23 Actual: 526.23 

DO NOT use keyboard input. Hard code all test values.

If a method has more than one outcome, you will require a test for each outcome. Ensure you indicate the test number for each test.

Avoid creating additional methods to reduce repetition in your test application. It is expected that some lines of code will be duplicated.

Here is the Financial class for reference:

Financial Class

Namespace: Last.First.Business

This static class contains functionality that includes financial functions.

Create the Financial class in the library project. This class must be defined under the Last.First.Business namespace.

Design

image text in transcribed

Methods

+ GetPayment(decimal, int, decimal) : decimal - Returns the payment amount for an annuity based on periodic, fixed payments and a fixed interest rate.

Parameters:

rate - the interest rate per period. For example, if the rate is an annual percentage rate (APR) of 10 percent and the customer makes monthly payments, the rate per period is 0.1 / 12, or 0.0083.

numberOfPaymentPeriods - the total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 12 (or 48) payment periods.

presentValue - the present value (or lump sum) that a series of payments to be paid in the future is worth now. For example, when a customer finances a car, the loan amount is the present value to the lender of the car payments the customer will make.

Exceptions:

ArgumentOutOfRangeException - Thrown when the rate is less than 0. Message: The argument cannot be less than 0. Parameter name: rate.

ArgumentOutOfRangeException - Thrown when the rate is greater than 1. Message: The argument cannot be greater than 1. Parameter name: rate.

ArgumentOutOfRangeException - Thrown when the number of payments is less than or equal to zero. Message: The argument cannot be less than or equal to 0. Parameter name: numberOfPaymentPeriods.

ArgumentOutOfRangeException - Thrown when the present value is less than or equal to zero. Message: The argument cannot be less than or equal to 0. Parameter name: presentValue.

The implementation for the GetPayment() method is:

image text in transcribed

"static" Financial +GetPayment(rate: decimal,_numberOfPaymentPeriods: int,_presentValue: decimal): decimal decimal futureValue =; decimal type =; decimal payment =; if (rate =0) payment = presentValue / numberOfPaymentPeriods; else payment = rate ( futureValue + presentValue (decimal)Math.Pow ( double) (1+ rate), (double)numbe rOfPaymentPeriods)) /((( decimal)Math.Pow ((double) (1+ rate), (double)numberOfPaymentPeriods) - 1) ( 1+ rate type))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions