This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class DatabaseFactory | |
{ | |
public static IDatabase Create() | |
{ | |
Database.UseMockAdapter(CreateMockAdapter()); | |
// This single line of code applies all these interfaces | |
return Impromptu.ActLike<IDatabase>(Database.Open()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class CustomerTest | |
{ | |
[Test] | |
public void TestInsert() | |
{ | |
var db = DatabaseFactory.Create(); | |
var customer = db.Customers.Insert(name: "Megadodo", location: "Ursa Minor Beta"); | |
Assert.AreEqual(1, customer.Id); | |
Assert.AreEqual("Megadodo", customer.Name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDatabase | |
{ | |
ICustomers Customers { get; } | |
IEmployees Employees { get; } | |
} | |
public interface ICustomers | |
{ | |
ICustomer Get(int id); | |
[UseNamedArgument] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* DISCLAIMER | |
This script is published only as a reference. | |
No warranty is implied or offered. | |
If you use this and bad things happen, it's not my fault. | |
*/ | |
/****** Object: Table [dbo].[action_history] Script Date: 13/11/2012 16:12:11 ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace AwaitChain | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Zudio.Common.Tests | |
{ | |
using System.Linq; | |
using Xunit; | |
public class StringSerializerTests | |
{ | |
[Fact] | |
public void SerializesNoStrings() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IL_0001: ldstr "bar" | |
IL_0006: stloc.0 // str | |
IL_0007: ldarg.0 | |
IL_0008: ldloc.0 // ldloc loads the variable onto the stack | |
IL_0009: call UserQuery.Foo | |
Foo: | |
IL_0000: nop | |
IL_0001: ldarg.1 | |
IL_0002: callvirt System.String.ToUpper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var account = new CloudStorageAccount(credentials); | |
var tasks = new List<Task>(); | |
foreach (var blobPath in blobPaths) | |
{ | |
var client = account.CreateCloudBlobClient(); | |
var blob = await client.GetBlobReferenceFromServerAsync(blobPath); | |
tasks.Add(blob.DeleteIfExistsAsync()); | |
} | |
await Task.WhenAll(tasks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Back up C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\schemas\html\commonHTML5Types.xsd | |
2. Delete C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\schemas\html\commonHTML5Types.bin if it exists | |
3. Replace it with the file below. | |
4. Restart Visual Studio 2012. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[FindAllUsers] | |
-- Add the parameters for the stored procedure here | |
AS | |
BEGIN | |
-- SET NOCOUNT ON added to prevent extra result sets from | |
-- interfering with SELECT statements. | |
SET NOCOUNT ON; | |
-- Insert statements for procedure here | |
SELECT * FROM tblUsers ORDER BY [name] |