This file contains hidden or 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
| using System; | |
| using System.Linq; | |
| using System.Reflection; | |
| using System.Reflection.Emit; | |
| using System.Threading; | |
| namespace MiniMock | |
| { | |
| public class Mockery | |
| { |
This file contains hidden or 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
| 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); |
This file contains hidden or 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
| 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, |
This file contains hidden or 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
| private static bool _MethodHasParameters(MethodInfo methodInfo) | |
| { | |
| return methodInfo.GetParameters().Count() > 0; | |
| } |
This file contains hidden or 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
| private static bool _MethodHasParameters(MethodInfo methodInfo) | |
| { | |
| return methodInfo.GetParameters().Count() > 1; | |
| } |
This file contains hidden or 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
| using System; | |
| using System.Linq; | |
| using System.Reflection; | |
| using System.Reflection.Emit; | |
| using System.Threading; | |
| namespace MiniMock.Mocking | |
| { | |
| public class Mockery | |
| { |
This file contains hidden or 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
| class StringReader | |
| def initialize(string) | |
| @string = string | |
| @current_index = -1 | |
| end | |
| def peek | |
| if end_of_string | |
| return nil | |
| end |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |