internal async Task TestDuplicateJobCreation() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { var service = new AgentService(); var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath); AgentNotebookInfo notebook = AgentTestUtils.GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master"); var createNotebookContext = new Mock <RequestContext <CreateAgentNotebookResult> >(); createNotebookContext.Setup(x => x.SendResult(It.IsAny <CreateAgentNotebookResult>())).Returns(Task.FromResult(new object())); await service.HandleCreateAgentNotebookRequest(new CreateAgentNotebookParams() { OwnerUri = connectionResult.ConnectionInfo.OwnerUri, Notebook = notebook, TemplateFilePath = AgentTestUtils.CreateTemplateNotebookFile() }, createNotebookContext.Object); createNotebookContext.Verify(x => x.SendResult(It.Is <CreateAgentNotebookResult>(p => p.Success == true))); await service.HandleCreateAgentNotebookRequest(new CreateAgentNotebookParams() { OwnerUri = connectionResult.ConnectionInfo.OwnerUri, Notebook = notebook, TemplateFilePath = AgentTestUtils.CreateTemplateNotebookFile() }, createNotebookContext.Object); createNotebookContext.Verify(x => x.SendResult(It.Is <CreateAgentNotebookResult>(p => p.Success == false))); await AgentTestUtils.CleanupNotebookJob(connectionResult, notebook); } }
internal async Task TestUpdateNonExistentJob() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { var service = new AgentService(); var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath); //getting a test notebook object AgentNotebookInfo notebook = AgentTestUtils.GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master"); var updateNotebookContext = new Mock <RequestContext <UpdateAgentNotebookResult> >(); updateNotebookContext.Setup(x => x.SendResult(It.IsAny <UpdateAgentNotebookResult>())).Returns(Task.FromResult(new object())); await service.HandleUpdateAgentNotebookRequest(new UpdateAgentNotebookParams() { OwnerUri = connectionResult.ConnectionInfo.OwnerUri, Notebook = notebook, TemplateFilePath = AgentTestUtils.CreateTemplateNotebookFile() }, updateNotebookContext.Object); // enpoint should error out updateNotebookContext.Verify(x => x.SendResult(It.Is <UpdateAgentNotebookResult>(p => p.Success == false))); } }