Unit testing for compiler errors
ADD
src/Chapter08.Tests/Listing08.04.CallingExplicitInterfaceMembersImplementations.Tests.cs
+using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter08.Listing08_04.Tests;
+
+[TestClass]
+public class ContactTests
+{
+ [TestMethod]
+ public async Task InvokingExplicitInterfaceMemberWithoutCast_CompileError()
+ {
+ await CompilerAssert.CompileAsync(
+ new string[] { "Listing08.04.CallingExplicitInterfaceMemberImplementations.cs", "Listing08.02.ImplementingAndUsingInterfaces.cs" },
+ new string[] { "CS1061" });
+ }
+}

ADD
src/Chapter08.Tests/Listing08.07.DeclarationWithoutContainingInterface.Tests.cs
+using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter08.Listing08_07.Tests;
+
+[TestClass]
+public class ContactTests
+{
+ [TestMethod]
+ public async Task DeclaringAMethodOnARelatedInterface_CompileError()
+ {
+ await CompilerAssert.CompileAsync(
+ new string[] { "Listing08.07.DeclarationWithoutContainingInterface.cs" },
+ new string[] { "CS0161", "CS0540" });
+ }
+}

Unit testing for compiler errors