Advantages of using unit-test frameworks.

Unit-testing frameworks are code libraries and modules that help developers unit-test their code.
The unit testing framework provides a class …


Technique of test-driven development

Test-driven development begins by writing a test that fails; then you move on to creating the production code, seeing …


Generic implementation of simple unit test in csharp

Unit-testing frameworks can help make helper methods more generic like this, so tests are written more easily.
Test implementation:

 
public class …


Simple unit test in csharp

Class to be tested:

public class SimpleNumber
{
public int ParseAndSum(string numbers)
{
if(numbers.Length==0)
{
return 0;
}
if(!numbers.Contains(","))
{
return int.Parse(numbers);
}
else
{
throw new InvalidOperationException(
"I can only handle 0 or 1 …


Characteristics of a good unit test

A unit test should have the following properties:

The unit test should be automated and repeatable.
The unit test should be …


Read file up to 1024 bytes of data in csharp

Stream stream = File.OpenRead(@"C:\data\file.xml");
int bytesToRead = 1024;
int bytesRead = 0;
byte [ ] buffer = new byte [bytesToRead];
 
// Fill up …


Array concatenation in Javascript

<HTML>
<HEAD>
<TITLE>Array Concatenation Example</TITLE>
<SCRIPT LANGUAGE=”JavaScript”>
// global variables
var arrayOne, arrayTwo, arrayThree, textObj
// initialize after load to access text object in form
function …


Setting Browser Status Message using Javascript

<HTML>
<HEAD>
<TITLE>window.defaultStatus property</TITLE>
<SCRIPT LANGUAGE=”JavaScript”>
window.defaultStatus = “Welcome to my Web site.”
</SCRIPT>
</HEAD>
<BODY>
<A HREF=”http://www.microsoft.com”
onMouseOver=”window.status = ‘Visit Microsoft\’s Home page.’;return true”
onMouseOut=”window.status = ‘’;return true”>Microsoft</A><P>
<A …


Check Before Closing a Window in Javascript

<HTML>
<HEAD>
<TITLE>window.closed Property</TITLE>
<SCRIPT LANGUAGE=”JavaScript”>
// initialize global var for new window object
// so it can be accessed by all functions on …


Csharp client side private caching

We can enable private caching if we specified a value of ‘Client’ for the Location attribute of an OutputCache …


Csharp Programmatically Setting Page Caching

The example code below shows a page whose expiration is set programmatically and uses the sliding expiration scheme. The …


VaryByParam,VaryByHeader, VaryByControl, VaryByCustom OutputCache Directive Attributes

VaryByCustom
Vary the output cache either by browser name and version or by a custom string, which must be handled …


CSharp OutputCache Directive Example

The OutputCache directive is added to the header of any ASP.NET page. It specifies the duration (in seconds) that …


LINQ to Objects: Query objects in LINQ

Language Integrated Query (LINQ, pronounced “link”) is a Microsoft .NET Framework component that adds native data querying capabilities to …


Popular Tags


RSS

 RSS Articles
eXTReMe Tracker