Skip to content

Instantly share code, notes, and snippets.

View yaplex's full-sized avatar

Alex Shapovalov yaplex

View GitHub Profile
[TestFixture]
public class ProductBLTests
{
[Test]
public void GetProductsTest()
{
MockRepository mocks = new MockRepository();
ProductDAL dal = (ProductDAL)mocks.StrictMock(typeof(ProductDAL));
using (mocks.Record())
{
$serviceName = "MyService"
if (Get-Service $serviceName -ErrorAction SilentlyContinue)
{
$serviceToRemove = Get-WmiObject -Class Win32_Service -Filter "name='$serviceName'"
$serviceToRemove.delete()
"service removed"
}
else
{
$secpasswd = ConvertTo-SecureString "MyPassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential (".\MYUser", $secpasswd)
$mycredentials = Get-Credential
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
System.Deployment.Application.ApplicationDeployment cd =
System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
string publishVersion = cd.CurrentVersion;
// show publish version in title or About box...
}
[OperationContract]
public string DoWork(string userName)
{
// Add your operation implementation here
return "Hello " + userName;
}
<input type="text" name="txtName" id="txtName" />
<input type="button" value="jQuery call" onclick="cityClickJQuery();" />
<input type="button" value="ASP.NET AJAX Call" onclick="cityClick();" />
function cityClickJQuery()
{
$.ajax({
type: "POST",
url: "http://localhost:65424/CityService.svc/DoWork",
data: '{"userName":"'+$get("txtName").value+'"}',
processData:false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data)
function cityClick()
{
CityService.DoWork($get("txtName").value, onSuccess);
}
function onSuccess(data)
{
if (data)
alert(data);
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>