Finished Defining a Delegate
parent
3b7e226312
commit
ae5b27fd2f
|
@ -4,8 +4,26 @@ using Xunit;
|
|||
namespace GradeBook.Tests
|
||||
{
|
||||
using GradeBook;
|
||||
|
||||
public delegate string WriteLogDelegate(string logMessage);
|
||||
|
||||
public class TypeTests
|
||||
{
|
||||
[Fact]
|
||||
public void WriteLogDelegateCanPointToMethod()
|
||||
{
|
||||
string msg = "test";
|
||||
|
||||
WriteLogDelegate log = new WriteLogDelegate(ReturnMessage); // Instantiate a delegate
|
||||
var result = log(msg); // Invoking a delegate
|
||||
Assert.Equal(result, msg);
|
||||
}
|
||||
|
||||
string ReturnMessage(string message)
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValueTypesAlsoPassByValue()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue