Deep Dive Into C# 9
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Contribute
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
TECHNOLOGIES
ANSWERS
LEARN
NEWS
BLOGS
VIDEOS
INTERVIEW PREP
BOOKS
EVENTS
CHAPTERS
ANNUAL CONFERENCE
CAREER
MEMBERS
JOBS
Creating NUnit Test Project
Kaushik S
Nov 11
2015
15.9k
0
0
In this article you will learn about Nunit test project.
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Print
Other Artcile
Expand
NunitTestProject.zip
Create a class library.
Manage Nuget package and install:
NUnit
NUnit Test Adapter for vs2012, vs2013 and vs2015
The reference should be added to class library,
Create a console project in the same solution and add the reference of the project to the class library.
In the unit test project add the below code to test the console project.
[TestFixture]
public
class
UnitTest1 {
DecimalToBinary obj =
null
;
Fibonacci fObj =
null
;
FizzBizz fbObj =
null
;
public
UnitTest1()
{
obj =
new
DecimalToBinary();
fObj =
new
Fibonacci();
fbObj =
new
FizzBizz();
}
[Test]
public
void
FizzBizzPass()
{
var ExpectedResult =
"Fizz"
;
var originalResult =
string
.Empty;
originalResult = fbObj.checkFizzBuzz(6);
Assert.AreEqual(ExpectedResult, originalResult);
}
[Test]
public
void
FizzBizzFail()
{
var ExpectedResult =
"FizzBizz"
;
var originalResult =
string
.Empty;
originalResult = fbObj.checkFizzBuzz(6);
Assert.AreEqual(ExpectedResult, originalResult);
}
[Test]
public
void
DecimalToBinaryPass()
{
var ExpectedResult =
"1000"
;
var originalResult =
string
.Empty;
originalResult = obj.getDecimalNumber(8);
Assert.AreEqual(ExpectedResult, originalResult);
}
[Test]
public
void
DecimalToBinaryFail()
{
var ExpectedResult =
"1001"
;
var originalResult =
string
.Empty;
originalResult = obj.getDecimalNumber(8);
Assert.That(ExpectedResult, Is.EqualTo(originalResult));
}
[Test]
public
void
FibonacciPass()
{
List <
int
> ExpectedResult =
new
List <
int
> ();
var result = fObj.GetFibonacci(1);
ExpectedResult.Add(0);
ExpectedResult.Add(1);
ExpectedResult.Add(1);
CollectionAssert.AreEqual(ExpectedResult, result);
}
[Test]
public
void
FibonacciFail()
{
List <
int
> ExpectedResult =
new
List <
int
> ();
var result = fObj.GetFibonacci(1);
ExpectedResult.Add(0);
ExpectedResult.Add(1);
ExpectedResult.Add(1);
ExpectedResult.Add(2);
CollectionAssert.AreEqual(ExpectedResult, result);
}
}
To test the methods,
Other ways to test
Install NUit
Download
.
Run Nunit and open the test project dll.
Click on run to know the output.
Next Recommended Article
Nuget package
Nunit project
FEATURED ARTICLES
View All
TRENDING UP
01
Deep Dive Into C# 9
02
How to Protect an Azure Storage Account using Shared Access Signatures
03
Sign-In Page Customization for Specific Branding in Azure
04
C# 8.x Next
05
SQL Functions Explained
06
Task Parallel Library 101 Using C#
07
Sending an Email to a Distribution List in Microsoft Flow
08
Install ALL Things SQL Server
09
Quick Look At Cognitive Service Content Moderator Web Application
10
Time Management In Organizations
View All