public void GetExecutionHistory_GivenNullArgs_Returns_InvalidDataContractException() { //------------Setup for test------------------------- var getExecutionHistory = new GetExecutionHistory(); var workspaceMock = new Mock <IWorkspace>(); //------------Execute Test--------------------------- var executeResults = getExecutionHistory.Execute(null, workspaceMock.Object); }
public void GetExecutionHistory_GetAuthorizationContextForService_Returns_Administrator() { //------------Setup for test------------------------- var getExecutionHistory = new GetExecutionHistory(); //------------Execute Test--------------------------- var authorizationContextForService = getExecutionHistory.GetAuthorizationContextForService(); //------------Assert Results------------------------- Assert.AreEqual(AuthorizationContext.Administrator, authorizationContextForService); }
public void GetExecutionHistory_CreateServiceEntry_Returns_GetExecutionHistory() { //------------Setup for test------------------------- var getExecutionHistory = new GetExecutionHistory(); //------------Execute Test--------------------------- var dynamicService = getExecutionHistory.CreateServiceEntry(); var handleType = getExecutionHistory.HandlesType(); //------------Assert Results------------------------- Assert.IsNotNull(dynamicService); Assert.IsFalse(string.IsNullOrEmpty(handleType)); Assert.AreEqual(handleType, dynamicService.Name); }
public void GetExecutionHistory_GivenEmptyArgs_Returns_ExecuteMessage() { //------------Setup for test------------------------- var getExecutionHistory = new GetExecutionHistory(); var workspaceMock = new Mock <IWorkspace>(); //------------Execute Test--------------------------- var requestArgs = new Dictionary <string, StringBuilder>(); var executeResults = getExecutionHistory.Execute(requestArgs, workspaceMock.Object); var jsonSerializer = new Dev2JsonSerializer(); Assert.IsNotNull(executeResults); var deserializedResults = jsonSerializer.Deserialize <IList <IExecutionHistory> >(executeResults); //------------Assert Results------------------------- Assert.IsNotNull(deserializedResults); Assert.AreEqual(0, deserializedResults.Count); }
public void GetExecutionHistory_Execute() { var stringBuilders = new Dictionary <string, StringBuilder> { { "ResourceId", new StringBuilder(GlobalConstants.DefaultLoggingSourceId) } }; var webSocketFactoryMock = new Mock <IWebSocketFactory>(); var webSocketWrapperMock = new Mock <IWebSocketWrapper>(); var commandMessage = ""; var onMessage = new Action <string, IWebSocketWrapper>((s, w) => { }); webSocketWrapperMock.Setup(ws => ws.SendMessage(It.IsAny <string>())).Callback((string s) => { commandMessage = s; }).Verifiable(); webSocketWrapperMock.Setup(c => c.Connect()).Returns(webSocketWrapperMock.Object); webSocketWrapperMock.Setup(ws => ws.OnMessage(onMessage)); webSocketFactoryMock.Setup(c => c.New()).Returns(webSocketWrapperMock.Object); //------------------------------Act-------------------------------------- var getExecutionHistory = new GetExecutionHistory(webSocketFactoryMock.Object, TimeSpan.FromMilliseconds(1)); getExecutionHistory.Execute(stringBuilders, null); //------------------------------Assert----------------------------------- var auditCommand = JsonConvert.DeserializeObject <AuditCommand>(commandMessage); Assert.IsNotNull(auditCommand); Assert.AreEqual("TriggerQuery", auditCommand.Type); Assert.AreEqual(1, auditCommand.Query.Count); Assert.AreEqual("ResourceId", auditCommand.Query.First().Key); Assert.AreEqual(GlobalConstants.DefaultLoggingSourceId, auditCommand.Query.First().Value.ToString()); webSocketWrapperMock.Verify(s => s.OnMessage(It.IsAny <Action <string, IWebSocketWrapper> >()), Times.Once); }