Question: Feedback ( Succeeded ) ( 5 / 5 points ) : Passed TestMethod 1 ( Succeeded ) ( 5 / 5 points ) : Passed
Feedback
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Succeeded points: Passed TestMethod
Failed points: Passed zTestExpected
ASSISTANT HINT # for
:
Make sure to test all the boundary cases, including the smallest and largest valid values, the smallest and largest invalid values, and the values that are just outside the valid range. Also, make sure to name your test cases as TestMethodX where X is a counter starting from it was incorrect and i cannot change anything outside of the comments including test case method
Using the definition for factorial from here and boundary analysis as described in the class video, write the set of Test Cases to test the C# function
int Factorialint n
which takes an integer n and returns the factorial if such number exists and can be calculated and throws ArgumentOutOfRangeException if the factorial doesn't exist or can't be calculated.
Name your Test Cases TestMethodX where X is a counter starting from
code: using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
TestClass
public partial class UnitTests
TestMethod
public void TestMethod
Assert.AreEqual Factorial;
Your code starts here
TestMethod : Factorial of should throw ArgumentOutOfRangeException
TestMethod
ExpectedExceptiontypeofArgumentOutOfRangeException
public void TestMethod
ComputeFactorial;
TestMethod : Factorial of should return
TestMethod
public void TestMethod
Assert.AreEqual ComputeFactorial;
TestMethod : Factorial of should return
TestMethod
public void TestMethod
Assert.AreEqual ComputeFactorial;
TestMethod : Factorial of largest valid value, should return
TestMethod
public void TestMethod
Assert.AreEqual ComputeFactorial;
TestMethod : Factorial of should throw ArgumentOutOfRangeException overflow
TestMethod
ExpectedExceptiontypeofArgumentOutOfRangeException
public void TestMethod
ComputeFactorial;
TestMethod : Factorial of int.MinValue, should throw ArgumentOutOfRangeException
TestMethod
ExpectedExceptiontypeofArgumentOutOfRangeException
public void TestMethod
ComputeFactorialintMinValue;
TestMethod : Factorial of valid upper boundary, should return
TestMethod
public void TestMethod
Assert.AreEqual ComputeFactorial;
TestMethod : Factorial of small valid value, should return
TestMethod
public void TestMethod
Assert.AreEqual ComputeFactorial;
TestMethod : Factorial of should throw ArgumentOutOfRangeException overflow test for larger values
TestMethod
ExpectedExceptiontypeofArgumentOutOfRangeException
public void TestMethod
ComputeFactorial;
Factorial function implementation
public int ComputeFactorialint n
if n n
throw new ArgumentOutOfRangeException;
if n return ;
int result ;
for int i ; i n; i
result i;
return result;
Your code ends here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
