Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C# Please! - Run your existing unit tests and ensure they all pass, specifically the ones testing the Withdrawl method. A failure would indicate

in C# Please!

- Run your existing unit tests and ensure they all pass, specifically the ones testing the Withdrawl method. A failure would indicate that the change to you Withdrawl method is not returning the expected results, meaning the method needs to be fixed.

- Create a new unit test to test the out of network functionality for your withdrawl method. You should verify that the Withdrawl method deducts an addtional $2.50 on top of the Withdrawl amount. Make sure you tests ALL outcomes you can think of from this scenario (HINT there are two).

- Write unit tests that assure your PayMortgage method is working as expected. Again, there are multiple scenarios here you will want to test. Don't simply test that the deducted principal is correct, as there are cases where the parameters fed in should produce different results (those edge cases I was reffering to earlier).

- Verify all tests pass

using Week3UnitTests.Model;

namespace Week3UnitTests.Test { [TestClass] public class UnitOfWorkTests { List _customers;

public UnitOfWorkTests() { _customers = new List() { new Customer() { Id = 1, FirstName = "Hulk", LastName = "Hogan", CurrentBalance = 200 }, new Customer() { Id = 2, FirstName = "Son", LastName = "Goku", CurrentBalance = 10 }, new Customer() { Id = 3, FirstName = "Bruce", LastName = "Wayne", CurrentBalance = 9001 } }; } [TestMethod] public void Deposit_UserExistsAndAmountGT0_AmountAddedToCurrentBalance() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act unitOfWork.Deposit(1, 20);

// assert Assert.AreEqual(220, _customers[0].CurrentBalance); }

[TestMethod] public void Deposit_UserExistsAndAmountLT0_ThrowsException() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act and assert Assert.ThrowsException( () => unitOfWork.Deposit(1, -20)); }

[TestMethod] public void Deposit_UserDoesNotExist_ThrowsException() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act and assert Assert.ThrowsException(() => unitOfWork.Deposit(11, 20)); }

[TestMethod] public void Withdrawal_UserExistsAndAmountIsNegative_CurrentBalanceDeducted() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act unitOfWork.Withdrawal(2, -20);

// asssert Assert.AreEqual(-10, _customers[1].CurrentBalance); }

[TestMethod] public void Withdrawal_UserExistsButAmountIsPostive_ThrowException() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act and assert Assert.ThrowsException(() => unitOfWork.Withdrawal(2, 20)); }

[TestMethod] public void Withdrawal_UserDoesNotExist_ThrowException() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act and assert Assert.ThrowsException(() => unitOfWork.Withdrawal(20, -20)); }

[TestMethod] public void GetBalance_UserDoesNotExist_ThrowException() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act and assert Assert.ThrowsException(() => unitOfWork.GetBalance(20)); }

[TestMethod] public void GetBalance_UserExists_ReturnsBalance() { // arrange UnitOfWork unitOfWork = new UnitOfWork(_customers);

// act decimal result = unitOfWork.GetBalance(3);

// assert Assert.AreEqual(9001, result); }

} }

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Calculate the missing quantities four-figure accuracy.

Answered: 1 week ago