From 4623c69c695678c2bd7c78e323d0a93eda7d19c1 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Mon, 22 Feb 2021 10:37:35 +0000 Subject: [PATCH] Finished Using Multi-cast Delegates --- gradebook/test/GradeBook.Tests/TypeTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gradebook/test/GradeBook.Tests/TypeTests.cs b/gradebook/test/GradeBook.Tests/TypeTests.cs index db76876..f98c9a1 100644 --- a/gradebook/test/GradeBook.Tests/TypeTests.cs +++ b/gradebook/test/GradeBook.Tests/TypeTests.cs @@ -9,18 +9,28 @@ namespace GradeBook.Tests public class TypeTests { + int count = 0; + [Fact] public void WriteLogDelegateCanPointToMethod() { string msg = "test"; WriteLogDelegate log = new WriteLogDelegate(ReturnMessage); // Instantiate a delegate + log += ReturnMessage2; // Multi-cast delegate var result = log(msg); // Invoking a delegate Assert.Equal(result, msg); + Assert.Equal(count, 2); } string ReturnMessage(string message) { + count += 1; + return message; + } + string ReturnMessage2(string message) + { + count += 1; return message; }