Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Thursday, June 14, 2012

Unlocker - System Utility

1) In PC, When we try to access a file or folder, some times we may get few annoying messages like below,

Cannot delete file: Access is denied
There has been a sharing violation.
The source or destination file may be in use.
The file is in use by another program or user.
Make sure the disk is not full or write-protected and that the file is not currently in use.

So, what is the main problem here, why we are unable to access these files or folders?
  Answer is these files/folders may be Locked.

To resolve these kind of issues, we have one handy utility : Unlocker,using which we can identify whether a file/folder has been locked or not, and can unlock the them.

Unlocker is an explorer extension. Once we finish with downloading and installation of Unlocker, all we need to is just right click on any of the file or folder (which we are unable to access) and select the unlocker option.

Then if the folder/file is locked, a window listing of lockers will appear.
Then we can take an appropriate action on that.
                                                     
           
  Thank you Rajesh Devabakthuni for letting me know about this utility.:)

Friday, June 24, 2011

NUnit Sample Application

Steps to use NUnit

1) First download current version of NUnit here.

2) Install it in your machine.

3) Create one sample Class Library in visual studio,and name it Calculations.

4) Now, we just write some small caluculation methods like Addition and Subtracton etc..

Code(cs file) will be like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculations
{
public class Calc
{
private int sum;
private int subtr;

public int Addition(int a, int b)
{
sum = a + b;
return sum;
}
public int Subtraction(int a, int b)
{
subtr = a - b;
return subtr;
}
static void Main(string[] args)
{
}
}
}


5) Then Create another class library, where we can write the test cases for the above methods.

Let us assume it as a NunitSampleTest.cs

a)For this Class library we need to add nunit reference.

If you have installed NUnit in C drive, You can find this reference from the below path
C:\Program Files\NUnit 2.5.10\bin\net-2.0\framework\nunit.framework.dll

b)Then we need to add Calculations referce.

Now we need to write the test cases as below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Calculations;
using NUnit.Framework;

namespace NUnitSampleTest
{
[TestFixture]
public class NUnitTestClass
{
[Test]
public void AdditionTest()
{
Calc newobj = new Calc();
int sum = newobj.Addition(20, 10);
Assert.AreEqual(30, sum);
}
[Test]
public void SubtractionTest()
{
Calc newobj = new Calc();
int subtr = newobj.Subtraction(20, 10);
Assert.AreEqual(10, subtr);
}
static void Main(string[] args)
{
}
}
}

[Note: In the above code we can find out two new attributes, i.e TestFixture and Test and one class Assert.
The TestFixture attribute is specified for the classes, When we attach this attribute to a class, the Test Runner application will scan it for test methods.
The only restrictions on classes that use the TestFixture attribute are that they must have a public default constructor (or no constructor which is the same thing).

The Test attribute marks a specific method inside a class that has already been marked as a TestFixture, as a test method.

Assertions are central to unit testing. The Assert claas provides a variety of static methods, using which we can test the result with the actual expected value.]

this all completes the codeing part

Now to test this application, we need to open NUnit UI, this we can find out at the below path
(C:\Program Files\NUnit 2.5.10\bin\net-2.0)
or
Goto start->All Programs ->NUnit 2.5.10


The window will be like as shown below




Now Goto File->open Project , then Go to the path and click on the NunitSampleTest.Dll



It will open the methods as shown below..





so right click on the individual methods or whole class and click on Run



If all the test cases are passed successfully, then we can see the green color Line as shown below




But if get Red color line, then it means TestCase is failed.



The above figure indicates that we have an issue in Subtraction Method..




Note: To Make things simpler we have hard coded the values in the TestCase methods.
Rather than hard coding the values, we can create one seperate class with values and can pass them to respective methods.

Friday, December 31, 2010

Logging Tool (Log4net)

LOGGING
It is an important component of the development cycle. It is the process of recording information with automated program. It is used to understand the activity of the application & to diagnose problems.

Features
- It provides precise context about the execution of the application.
- Once inserted into the code, the generation of logging output requires no human intervention.
- Log output can be saved in persistent medium to be studied at a later time.

Log4net

Its an open source library that allows .NET applications to output log statements to a variety of output targets such as to a file,the console, the database or even e.mail.
It allows the developer to control which log statements are output with arbitrary granularity. It is fully configurable at run time using external configuration files.

Features:

- log4net is optimized for speed.
- log4net is based on a named logger hierarchy.
- log4net is fail-stop but not reliable.
- log4net is thread-safe.
- log4net is not restricted to a predefined set of facilities.
- Logging behavior can be set at run time using a configuration file. Configuration files are in XML format.
- log4net is designed to handle exceptions from the start.
- log4net categorizes logging into levels: DEBUG, INFO, WARN, ERROR and FATAL.
- The format of the log output can be easily changed by implementing a new layout class.
- The target of the log output as well as the writing strategy can be altered by writing a new appender class.
- log4net supports multiple output appenders per logger.

Log4net can be downloaded from here. Log4net Download


Log4net is from the The Apache Software Foundation
Note:It can slow down the application.

Other Logging frameworks are
- log4j for Java
- log4cxx for C++
- log4php for PHP

Thursday, December 30, 2010

FIREBUG (Development Tool)

FIREBUG

Firebug, an open source extension for the Mozilla Firefox Browser, provides tools to monitor, edit, and debug any website's CSS, HTML, DOM, and JavaScript.

It also has a JavaScript console for logging errors and watching values, as well as a "Net" feature which monitors the amount of time in milliseconds it takes to execute scripts and load images on the page.

CSS, HTML: In live we can edit the CSS & HTML of any web page & can view the result.

JavaScript : using firebug we can debug the JavaScript code by putting breakpoints & we can log the errors.

Network Monitor :
This Feature lets you monitor how much time is spent when loading a web page. Use the Net tab to see the bar that shows when a file started and stopped loading relative to all other files. Network Monitor breaks up the traffic on a file-by-file basis so we can see how much time is spent loading image, JavaScript, HTML, and so forth.



Steps:

1) Download Firebug from http://getfirebug.com/downloads.

2) Install into the Web browser. Restart the browser.

3) By going to any web page press f12 then you can see the window at the bottom of the page.

Note:
-The edited HTML or CSS or JavaScript wont effect the existing code.
-There is also a Firebug Lite version for Internet Explorer, Opera and Safari.

(Courtesy by my  colleague Victor)