public async Task RequestParametersTest() { // Arrange - Clients var mockClients = new Mock <IHubCallerConnectionContext <IIdeHubClient> >(); var mockCaller = new Mock <IIdeHubClient>(); mockClients.Setup(m => m.Caller).Returns(mockCaller.Object); // Arrange - Context var context = new HubCallerContext(null, "RequestParametersTestConnection"); // Arrange - Hub var hub = new IdeHub(new IdeServices(new CodeRunner())) { Clients = mockClients.Object, Context = context }; // Act // N.b. we specifically test DateTime.Parse, because: // a) it has several overloads, and // b) some of its parameter types have C# aliases and some don't await hub.RequestParameters("System.DateTime.Parse(\"\", null, System.Globalization.DateTimeStyles.None)", 50, 1234); // Assert mockCaller.Verify(m => m.ParamsCallback(It.Is <Overloads>(o => VerifyDateTimeParseOverloads(o)), 1234)); }
public async Task BuiltInReturnTypeTest() { // Arrange - Clients var mockClients = new Mock <IHubCallerConnectionContext <IIdeHubClient> >(); var mockCaller = new Mock <IIdeHubClient>(); mockClients.Setup(m => m.Caller).Returns(mockCaller.Object); // Arrange - Context var context = new HubCallerContext(null, "BuiltInReturnTypeTestConnection"); // Arrange - Hub var hub = new IdeHub(new IdeServices(new CodeRunner())) { Clients = mockClients.Object, Context = context }; // Act await hub.RequestParameters("System.Console.ReadLine()", 24, 4321); // Assert mockCaller.Verify(m => m.ParamsCallback(It.Is <Overloads>(o => VerifyReadLineParseOverloads(o)), 4321)); }
public async Task AfterParamsTest() { // Arrange - Clients var mockClients = new Mock <IHubCallerConnectionContext <IIdeHubClient> >(); var mockCaller = new Mock <IIdeHubClient>(); mockClients.Setup(m => m.Caller).Returns(mockCaller.Object); // Arrange - Context var context = new HubCallerContext(null, "AfterParamsTestConnection"); // Arrange - Hub var hub = new IdeHub(new IdeServices(new CodeRunner())) { Clients = mockClients.Object, Context = context }; // Act await hub.RequestParameters("System.Console.ReadLine()", 25, 4321); // Assert mockCaller.Verify(m => m.ParamsCallback(It.IsAny <Overloads>(), It.IsAny <int>()), Times.Never); }