About Me

My photo
a Dynamic and Energetic guy.....

Sunday, December 20, 2009

BlackBox testing Vs. WhiteBox testing

White box testing refers to testing that works with the application's internals (or code). White box (or glass box) testing is typically done by developers using the IDE, debugger, and unit tests. This is going into the deep of logic & verifies the function.

Integration testing is considered functional, or black box, testing. Testers write test cases that indicate a given input into the application. Based on this input, they make assumptions about the output of the application. The testers then execute these integration tests as a black box. That is, they do not care about what happens inside the box (the code); they simply care that they get the expected results based on the given input.



Source:- 70-547 training kit book

Friday, December 18, 2009

Testing Our Code (As a Developer I Should)

Rules

Success baseline Start by defining a unit test that represents a common, successful path through your code. This test should represent the most likely scenario for executing your code.

Parameter mix Create a unit test that provides a varied mixture of parameters for a given method. This will ensure that more than just the success path works effectively. Consider creating this scenario as a data-driven unit test.

Bounds checking Create one or more unit tests that test the upper and lower limits of your code. That is, if your method takes a numeric value, you will want to test that method with values that represent both the upper and lower range of the data type.

Null values Make sure your unit tests measure what happens when null values are passed to a given method or property.

Error conditions Create unit tests that trigger error conditions in your code. You can tell the unit test that you expect a certain error as a result. If that error is not thrown, then the test will fail.

Code coverage scenarios Make sure that all the code in your method is called by one or more unit tests. You do not want untested code sitting inside of conditional statements. If this happens, write tests that hit those conditions inside your application code.


 


 

Best Practices

  • Write one test for each scenario you should test each outcome or scenario independently. If your method has a number of expected outcomes, write a test for each scenario.
  • Create atomic unit tests your unit tests should not require others tests (or a sequence of tests) to be run prior to their execution or as part of their execution.
  • Cover all conditions your unit tests should cover all cases. An effective set of unit tests covers every possible condition for a given method, including bounds checks, null values, exceptions, and conditional logic.
  • Run without configuration your unit tests should be easy to run (and rerun). They should not require setup or configuration. You do not want to define tests that require a specific environment every time you run your tests (or they will not be run). If setup is required, code that into a test-initialize script.
  • Test a common application state your unit tests should be run against a common, standard, good state. For example, if your application works with data, this data should be set to common state prior to the execution of each unit test. This ensures that one test is not causing an error in another test.


Source:- 70-547 training kit book

Sending Email Using Web.Config Entries in .NET

// Web.Config sample

<configuration>

<system.net>

<mailSettings>

<smtp from="website@website.com">

<network host="mail.website.com" password="" userName=""/>

</smtp>

</mailSettings>

</system.net>

</configuration>




// Code sample

using System.Net.Mail;

MailSettingsSectionGroup mailSettings = WebConfigurationManager.GetSection("system.net/

mailSettings") as MailSettingsSectionGroup;


protected void SendingEmail()

{

// Sending E-Mail

MailMessage message = new MailMessage(mailSettings.Smtp.From, WebConfigurationManager.AppSettings["RecipientList"], "Sending E-mail using web.config", "");

message.Priority = MailPriority.High;

SmtpClient smtp = new SmtpClient(mailSettings.Smtp.Network.Host);

smtp.Send(message);

}

Monday, December 7, 2009

Multi-tier Architecture in application development

We can categorize our n- tier architecture into 3 sections

  1. User Interface

    Presentation

    User interface code

    Business logic interaction code

  2. Middle Layer

    Business layer

    Application layer

    Database layer (This layer abstracts the retrieval and storage of data in your database)

  3. Database Layer

    Database layer

    Stored procedures

    Integration services

    Database tables, logs & indexes


 

Reference:-

MCPD (70-547) Designing and Developing Web-Based Applications Using the .NET Framework

Time Update using AJAX Controls

<div>


<cc1:ToolkitScriptManager
ID="ToolkitScriptManager1"
runat="server">

</cc1:ToolkitScriptManager>

<asp:UpdatePanel
ID="UpdatePanel1"
runat="server">

<ContentTemplate>

 
<asp:Panel
runat="server"
id="TimerArea">

<div
style="width: 100%; height: 100%; vertical-align: middle; text-align: center;">

<p>Current Time using AJAX control:</p>

<span
id="currentTime"
runat="server"
style="font-size:xx-large;font-weight:bold;line-height:40px;"/>

</div>

</asp:Panel>


<cc1:AlwaysVisibleControlExtender
ID="UpdatePanel1_AlwaysVisibleControlExtender"

runat="server"
Enabled="True"
TargetControlID="TimerArea">

</cc1:AlwaysVisibleControlExtender>


</ContentTemplate>

</asp:UpdatePanel>

 
<script
type="text/javascript"
language="javascript">

function updateTime()
{

var label = document.getElementById('currentTime');

if (label) {

var time = (new Date()).localeFormat("T");
label.innerHTML = time;
}
}
updateTime();
window.setInterval(updateTime, 1000);

</script>



</div>

ASP.NET Concepts & theory

ASPX page execution order

Page_PreInit()
Page_Init()
Page_InitComplete()
Page_PreLoad()
Page_Load()
Page_LoadComplete()
Page_Prerender()
Page_Render()
Page_Unload()







Friday, December 4, 2009

Partial Methods in C#

This is a cool feature that comes with C#.
We can define a method & can omit the logic of that method, that is called Partial method.

If the implementation is not supplied, then the method and all calls to the method are removed at compile time.
This is useful as a way to customize generated code & the developer can work of same method without run-time problems. Because it is separated. We can validate data before it executes using these types of partial methods.

* Partial method should inside Partial Class
  • Partial method declarations must begin with the contextual keyword partial and the method must return void.

  • Partial methods can have ref but not out parameters.

  • Partial methods are implicitly private , and therefore they cannot be virtual.


// Code-generating tool defines a partial class, including
// two partial methods.
partial class ExampleClass
{
partial void onFindingMaxOutput();
partial void onFindingMinOutput();
}

// Developer implements one of the partial methods.
// Compiler
discards the signature of the other method.
partial class ExampleClass
{
partial void onFindingMaxOutput()
{
Console.WriteLine("Maximum has been found.");
}
}

Friday, November 20, 2009

Mockups Vs. Proof-of-Concept Prototypes

There are many types of prototypes. Some projects create UI prototypes. Others might proto-
type an architecture consideration. In fact, every project has different needs regarding a prototype.
However, for your purposes, these prototypes can be classified into two principal groups:
mockups and proof of concept.

A mockup is meant to verify the requirements and use cases through the creation of a number
of key screens in the system. Also called horizontal prototypes because they take
a single, horizontal picture of the application. They do not go deeply (or vertically) into the
other layers of the application such as the business objects and the database layers. Mockups
are a great way to determine whether the requirements are complete and understood. They
also help validate the use cases, the navigational structure, and some of the logical interactions
of the application.

Mockups do have shortcomings. They do not help you prove any of the architecture concepts
for the system. They also do not validate the technology decisions. Mockups are
great tool for moving from paper to something more tangible.

A proof-of-concept prototype(POC) is meant to validate the requirements and confirm the technology recommendations and high-level design. A POC is also called a vertical
prototype because it looks at the application across the entire stack (UI, services, business objects, and database). POC prototypes have also been called reference architectures,
because they provide a reference for the development team on just how the system
should work from top to bottom. This removes ambiguity, creates a standard, and eliminates
a lot of risk.
We create a POC prototype by choosing a key requirement of the application and
then building it out through each layer of the design. It makes more sense to prove out a riskier
requirement than to work with a well-known requirement. The latter might be easy, but it lacks
the risk reduction you are looking for with a proof of concept.

Sunday, November 15, 2009

Deploy 40 templates (.wsp solution) to sharepoint

first go to
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN

then type
stsadm –o addsolution –filename ApplicationTemplateCore.wsp

stsadm –o deploysolution –name ApplicationTemplateCore.wsp -allowgacdeployment -local

stsadm -o copyappbincontent

then go to central administration --> Operations --> Solution management

You can see your solution there(ApplicationTemplateCore).

Now you have to add your necessary templates...
Same as early
stsadm –o addsolution –filename ApplicationTemplateCore.wsp
stsadm –o deploysolution –name ApplicationTemplateCore.wsp -allowgacdeployment -local

Now go to central administration with a hope !
Create new site collection -->
Under application templates --> you will have your template(s)

:)

Thursday, October 29, 2009



When we add controls dynamically, we are getting error like this.
Then we have to add this code to .ASPX file's code

public override void VerifyRenderingInServerForm(Control control)
{
Confirms that an HtmlForm control is rendered for the
specified ASP.NET server control at run time.
No code required here.
}


Then we are all works fine :) :) :)

My Masters