CreateFakeEvent() public static method

public static CreateFakeEvent ( ) : Microsoft.Azure.Insights.Models.EventData
return Microsoft.Azure.Insights.Models.EventData
Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public static AzureOperationResponse <LogProfileResource> InitializeLogProfileResponse()
        {
            // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet
            EventData eventData = Utilities.CreateFakeEvent();
            var       x         = JsonConvert.SerializeObject(eventData);

            return(new AzureOperationResponse <LogProfileResource>()
            {
                Body = new LogProfileResource(
                    name: Utilities.Name,
                    location: "East US",
                    id: "MyLogProfileId",
                    locations: new string[] { "EastUs" },
                    categories: new List <string>()
                {
                    "cat2"
                },
                    retentionPolicy: new RetentionPolicy(enabled: true, days: 10))

                {
                    ServiceBusRuleId = "myBusId",
                    StorageAccountId = "myStorageAccId",
                    Tags = null
                }
            });
        }
Ejemplo n.º 3
0
        public static AzureOperationResponse <IPage <EventData> > InitializeResponse()
        {
            // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet
            EventData eventData = Utilities.CreateFakeEvent();
            var       x         = JsonConvert.SerializeObject(eventData);

            return(new AzureOperationResponse <IPage <EventData> >()
            {
                Body = JsonConvert.DeserializeObject <Azure.Insights.Models.Page <EventData> >(x)
            });
        }
Ejemplo n.º 4
0
        public static MetricDefinitionListResponse InitializeMetricDefinitionResponse()
        {
            // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet
            EventData eventData = Utilities.CreateFakeEvent();

            return(new MetricDefinitionListResponse
            {
                MetricDefinitionCollection = new MetricDefinitionCollection
                {
                    Value = new MetricDefinition[] {}
                },
                RequestId = Guid.NewGuid().ToString(),
                StatusCode = HttpStatusCode.OK
            });
        }
Ejemplo n.º 5
0
        public static EventDataListResponse InitializeResponse()
        {
            // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet
            EventData eventData = Utilities.CreateFakeEvent();

            return(new EventDataListResponse()
            {
                EventDataCollection = new EventDataCollection()
                {
                    Value = new List <EventData>()
                    {
                        eventData,
                    },
                    NextLink = null,
                },
                RequestId = Guid.NewGuid().ToString(),
                StatusCode = HttpStatusCode.OK
            });
        }