Friday

t-sql unit testing

Here is simple t-sql unit testing approach by writing sql script that will do all testing work.
I like this solution the most because it's very flexible and doesn't require additional installations on sql server.


Also I think the best way to write sql unit tests is to make them independent from data.And validate logic but not data.
Such unit tests can be run on development or qa and even production environment.
 
--Unit Test example
--SETUP
declare @ActualData varchar(10) , @ExpectedResult varchar(10)

-- RUN
SET @ActualData ='a'
Set @ExpectedResult ='b'

-- VALIDATE
IF @ActualData!= @ExpectedResult
RAISERROR('>> Unit Test FAILED: Returned data doen''t match expected: %s instead of %s ', 11, 0, @ActualData ,@ExpectedResult )

Also there are another sql unit test frameworks .

Tuesday

jquery textbox change event not firing

Try to use live event instead of change or onchange as follows:
 
$('#myTextBoxId').live('input', function () {
MyFunction();
});


Monday

jquery select add remove item


to add new option to select control with DropDownId id :
 
$('#DropDownId').append(new Option('text','val'));



to remove option to select control with DropDownId id:
 
$("#DropDownId option[value='val1']").remove();
$("#DropDownId option:contains('val1')").remove();


mvc model not updating

To resolve this issue try to add this instruction before calling view and see if it works ModelState.Clear();
  
public ViewResult SomeAction(SomeModel model)
{
var newModel = new SomeModel { SomeString = "some value" };
ModelState.Clear();
return View(model);
}


test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...