public void ShouldBeAbleToAddNewMethodOverloadsFromDelegates() { var writtenLines = new List <string>(); Action <string> writeLine1 = text => { writtenLines.Add(text); }; Action <string, string> writeLine2 = (arg1, arg2) => { writtenLines.Add($"{arg1} {arg2}"); }; dynamic foo = new MetaObject(); foo.WriteLine = writeLine1; foo.WriteLine = writeLine2; foo.WriteLine("Hello, World!"); foo.WriteLine("Hi", "Everyone!"); Assert.Contains(writtenLines, text => text == "Hello, World!"); Assert.Contains(writtenLines, text => text == "Hi Everyone!"); }
public void ShouldBeAbleToAddNewMethodsFromDelegates() { var writtenLines = new List <string>(); Action <string> writeLine = text => { writtenLines.Add(text); }; dynamic foo = new MetaObject(); foo.WriteLine = writeLine; foo.WriteLine("Hello, World!"); Assert.Single(writtenLines, text => text == "Hello, World!"); }