public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output cmdlet.DetailedOutput = true; cmdlet.ExecuteCmdlet(); Assert.Null(selected); // Incorrect nameOrTargetUri clause with detailed output on }
public static void VerifyContinuationToken(EventDataListResponse response, Mock <IEventOperations> insinsightsEventOperationsMockightsClientMock, EventCmdletBase cmdlet) { // Make sure calls to Next work also response.EventDataCollection.NextLink = Utilities.ContinuationToken; var responseNext = new EventDataListResponse() { EventDataCollection = new EventDataCollection() { Value = new List <EventData>() { Utilities.CreateFakeEvent(), }, NextLink = null, }, RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK }; string nextToken = null; insinsightsEventOperationsMockightsClientMock.Setup(f => f.ListEventsNextAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <EventDataListResponse>(responseNext)) .Callback((string n, CancellationToken t) => nextToken = n); // Calling without optional parameters cmdlet.ExecuteCmdlet(); Assert.True(string.Equals(Utilities.ContinuationToken, nextToken, StringComparison.OrdinalIgnoreCase), "Incorrect continuation token"); }
public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output cmdlet.DetailedOutput = true; cmdlet.ExecuteCmdlet(); Assert.True(string.Equals(null, selected, StringComparison.OrdinalIgnoreCase), "Incorrect selected clause with detailed output on"); }
public static void ExecuteVerifications(EventCmdletBase cmdlet, Mock <IEventOperations> insinsightsEventOperationsMockightsClientMock, string requiredFieldName, string requiredFieldValue, ref string filter, ref string selected, DateTime startDate, EventDataListResponse response) { // Calling without optional parameters cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: null); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); Assert.True(string.Equals(PSEventDataNoDetails.SelectedFieldsForQuery, selected, StringComparison.OrdinalIgnoreCase), "Incorrect nameOrTargetUri clause without optional parameters"); // Calling with only start date cmdlet.StartTime = startDate; cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: startDate); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); // Calling with only start and end date cmdlet.EndTime = startDate.AddSeconds(2); cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: startDate); VerifyEndDateInFilter(filter: filter, endDate: startDate.AddSeconds(2)); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); // Calling with only caller cmdlet.EndTime = null; cmdlet.Caller = Utilities.Caller; cmdlet.ExecuteCmdlet(); VerifyCallerInCall(filter: filter, startDate: startDate, filedName: requiredFieldName, fieldValue: requiredFieldValue); // Calling with caller and status cmdlet.Status = Utilities.Status; cmdlet.ExecuteCmdlet(); VerifyStatusAndCallerInCall(filter: filter, startDate: startDate, filedName: requiredFieldName, fieldValue: requiredFieldValue); VerifyDetailedOutput(cmdlet: cmdlet, selected: ref selected); VerifyContinuationToken(response: response, insinsightsEventOperationsMockightsClientMock: insinsightsEventOperationsMockightsClientMock, cmdlet: cmdlet); // Execute negative tests cmdlet.StartTime = DateTime.Now.AddSeconds(1); Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet()); cmdlet.StartTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(20)); cmdlet.EndTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(21)); Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet()); cmdlet.StartTime = DateTime.Now.Subtract(TimeSpan.FromDays(30)); cmdlet.EndTime = DateTime.Now.Subtract(TimeSpan.FromDays(14)); Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet()); }
public static void VerifyContinuationToken(AzureOperationResponse <IPage <EventData> > response, Mock <IEventsOperations> insinsightsEventOperationsMockightsClientMock, EventCmdletBase cmdlet) { // Make sure calls to Next work also string nextToken = ContinuationToken; insinsightsEventOperationsMockightsClientMock.Setup(f => f.ListNextWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <AzureOperationResponse <IPage <EventData> > >(response)) .Callback((string n, Dictionary <string, List <string> > h, CancellationToken t) => nextToken = n); // Calling without optional parameters cmdlet.ExecuteCmdlet(); Assert.Equal(Utilities.ContinuationToken, nextToken, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public static void ExecuteVerifications(EventCmdletBase cmdlet, Mock<IEventOperations> insinsightsEventOperationsMockightsClientMock, string requiredFieldName, string requiredFieldValue, ref string filter, ref string selected, DateTime startDate, EventDataListResponse response) { // Calling without optional parameters cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: null); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); Assert.True(string.Equals(PSEventDataNoDetails.SelectedFieldsForQuery, selected, StringComparison.OrdinalIgnoreCase), "Incorrect nameOrTargetUri clause without optional parameters"); // Calling with only start date cmdlet.StartTime = startDate; cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: startDate); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); // Calling with only start and end date cmdlet.EndTime = startDate.AddSeconds(2); cmdlet.ExecuteCmdlet(); VerifyFilterIsUsable(filter: filter); VerifyStartDateInFilter(filter: filter, startDate: startDate); VerifyEndDateInFilter(filter: filter, endDate: startDate.AddSeconds(2)); VerifyConditionInFilter(filter: filter, field: requiredFieldName, value: requiredFieldValue); // Calling with only caller cmdlet.EndTime = null; cmdlet.Caller = Utilities.Caller; cmdlet.ExecuteCmdlet(); VerifyCallerInCall(filter: filter, startDate: startDate, filedName: requiredFieldName, fieldValue: requiredFieldValue); // Calling with caller and status cmdlet.Status = Utilities.Status; cmdlet.ExecuteCmdlet(); VerifyStatusAndCallerInCall(filter: filter, startDate: startDate, filedName: requiredFieldName, fieldValue: requiredFieldValue); VerifyDetailedOutput(cmdlet: cmdlet, selected: ref selected); VerifyContinuationToken(response: response, insinsightsEventOperationsMockightsClientMock: insinsightsEventOperationsMockightsClientMock, cmdlet: cmdlet); // Execute negative tests cmdlet.StartTime = DateTime.Now.AddSeconds(1); Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet()); cmdlet.StartTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(20)); cmdlet.EndTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(21)); Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet()); cmdlet.StartTime = DateTime.Now.Subtract(TimeSpan.FromDays(30)); cmdlet.EndTime = DateTime.Now.Subtract(TimeSpan.FromDays(14)); Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet()); }
public static void VerifyContinuationToken(EventDataListResponse response, Mock<IEventOperations> insinsightsEventOperationsMockightsClientMock, EventCmdletBase cmdlet) { // Make sure calls to Next work also response.EventDataCollection.NextLink = Utilities.ContinuationToken; var responseNext = new EventDataListResponse() { EventDataCollection = new EventDataCollection() { Value = new List<EventData>() { Utilities.CreateFakeEvent(), }, NextLink = null, }, RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK }; string nextToken = null; insinsightsEventOperationsMockightsClientMock.Setup(f => f.ListEventsNextAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<EventDataListResponse>(responseNext)) .Callback((string n, CancellationToken t) => nextToken = n); // Calling without optional parameters cmdlet.ExecuteCmdlet(); Assert.True(string.Equals(Utilities.ContinuationToken, nextToken, StringComparison.OrdinalIgnoreCase), "Incorrect continuation token"); }
public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output cmdlet.DetailedOutput = true; cmdlet.ExecuteCmdlet(); Assert.Null(selected); // Incorrect nameOrTargetUri clause with detailed output on }
public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output cmdlet.DetailedOutput = true; cmdlet.ExecuteCmdlet(); Assert.True(string.Equals(null, selected, StringComparison.OrdinalIgnoreCase), "Incorrect selected clause with detailed output on"); }
public static void VerifyContinuationToken(AzureOperationResponse<IPage<EventData>> response, Mock<IEventsOperations> insinsightsEventOperationsMockightsClientMock, EventCmdletBase cmdlet) { // Make sure calls to Next work also string nextToken = ContinuationToken; insinsightsEventOperationsMockightsClientMock.Setup(f => f.ListNextWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<AzureOperationResponse<IPage<EventData>>>(response)) .Callback((string n, Dictionary<string, List<string>> h, CancellationToken t) => nextToken = n); // Calling without optional parameters cmdlet.ExecuteCmdlet(); Assert.Equal(Utilities.ContinuationToken, nextToken, ignoreCase:true, ignoreLineEndingDifferences:true,ignoreWhiteSpaceDifferences:true); }