Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
namespace MiniMock
{
public class Mockery
{
private static void _GenerateMethod_Without_Return(TypeBuilder typeBuilder, string firstMethodName, Type[] parameterTypes)
{
var methodBuilder = typeBuilder.DefineMethod(
firstMethodName,
MethodAttributes.Public | MethodAttributes.Virtual,
typeof (void),
parameterTypes);
var methodIl = methodBuilder.GetILGenerator();
methodIl.Emit(OpCodes.Ret);
private static void _GenerateMethod_With_Return(
MethodInfo methodInfo,
TypeBuilder typeBuilder,
string firstMethodName,
Type[] parameterTypes)
{
var returnType = methodInfo.ReturnType;
var methodBuilder = typeBuilder.DefineMethod(
firstMethodName,
MethodAttributes.Public | MethodAttributes.Virtual,
private static bool _MethodHasParameters(MethodInfo methodInfo)
{
return methodInfo.GetParameters().Count() > 0;
}
private static bool _MethodHasParameters(MethodInfo methodInfo)
{
return methodInfo.GetParameters().Count() > 1;
}
using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
namespace MiniMock.Mocking
{
public class Mockery
{
class StringReader
def initialize(string)
@string = string
@current_index = -1
end
def peek
if end_of_string
return nil
end
require 'StringReader'
describe "When reading past last character in the string" do
before(:each) do
@string_reader = StringReader.new("ab")
@string_reader.read
@string_reader.read
end
it "should return None" do
Normal:
describe "When reading past last character in the string" do
before(:each) do
@string_reader = StringReader.new("ab")
@string_reader.read
@string_reader.read
end
it "should asplode!" do
describe "When building a three pattern with a match any multiple in the middle" do
before(:each) do
@state_builder = StateBuilder.new
@string_reader = StringReader.new("a*.")
@graph = @state_builder.create_from(@string_reader)
end
it "should return a five state graph" do
@graph.transitions[0].destination.transitions[0].destination.transitions[0].destination.transitions[0].destination.should_not == nil
end