Skip to content

Instantly share code, notes, and snippets.

View ElemarJR's full-sized avatar
🏠
Working from home

Elemar Rodrigues Severo Junior ElemarJR

🏠
Working from home
View GitHub Profile
using System.IO.Fakes;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace FakesDemo.Tests
{
[TestClass]
public class FileHelperTests
{
[TestMethod]
public static class FileHelper
{
public static bool IsValid(string fileName)
{
return File.ReadAllText(fileName).Length > 0;
}
}
[TestMethod]
public void Ctor_WhenShouldBeNow()
{
using (ShimsContext.Create())
{
ShimDateTime.NowGet = () => new DateTime(2012, 09, 06);
var entry = new LogEntry("Hello World!");
Assert.AreEqual(DateTime.Now, entry.When);
}
}
public class LogEntry
{
class DefaultCurrentDateProvider
: ICurrentDateProvider
{
public DateTime GetCurrentDate()
{
return DateTime.Now;
}
}
public class LogEntry
{
public LogEntry(string message, IOutput output = null)
{
this.When = DateTime.Now;
this.Message = message;
if (output != null)
output.Write(this);
}
@ElemarJR
ElemarJR / funWithHttp.cs
Created August 21, 2012 14:06
Fun with HTTP
using System;
using System.Text;
using System.Linq;
using System.Net;
using System.Net.Sockets;
namespace MyHttpServer
{
class SimpleHttpServer
{
var image = new Image();
image.src = "../images/smurf_sprite.png";
$(image).load(function () {
animate();
});
function animate() {
update();
draw();
var query = (
from address in addresses
from order in orders
where address.AddressID == order.Address.AddressID
&& address.City == "Seattle"
orderby order.SalesOrderID
select new
{
City = address.City,
OrderID = order.SalesOrderID,
IFoo f1 = new SomeConcreteFoo();
var f2 = (IFoo) (new SomeConcreteFoo());
var account = new Account();
var tasks = new Task[10];