public async Task CreateAndRunScript() { // Arrange var context = new TestCaseContext(); var sut = new ScriptHost( context.Options, context.Logger, context.ScriptLogger, context.StringEncoder, context.SessionManager, context.ServiceProvider); var scriptName = "testScript"; var a = 3; var b = 7; var code = $@" var a = {a}; var b = {b}; var c = a + b; Logger.LogDebug($""Running script {{ScriptName}}; Sum = {{c}}; Session = {{Session.Id}}"");"; // Act + Assert var script = sut.CreateScript(scriptName, code); Assert.NotNull(script); Assert.Equal(scriptName, script.Name); Assert.NotNull(script.Script); Assert.Equal(typeof(HellScriptContext), script.ContextType); await sut.RunScript(script, context.Session.Id); Func <object, Type, bool> expectedState = (v, t) => v.ToString().CompareTo($"Running script {scriptName}; Sum = {a + b}; Session = {context.Session.Id}") == 0; Mock.Get(context.ScriptLogger).Verify( m => m.Log( LogLevel.Debug, It.IsAny <EventId>(), It.Is <It.IsAnyType>((v, t) => expectedState(v, t)), It.IsAny <Exception>(), It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true)), Times.Once); }