public void GetUniqueCosmosDbCollectionNamesFromEventData_GivenMultiplEventsForSameCollectionWhereStatusCodeIs429_ReturnsCollectionWithOneItem()
        {
            //Arrange
            EventData eventData1 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData1.Properties.Add("statusCode", 429);
            eventData1.Properties.Add("collection", "calcs");

            EventData eventData2 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData2.Properties.Add("statusCode", 429);
            eventData2.Properties.Add("collection", "calcs");

            IEnumerable <EventData> events = new[]
            {
                eventData1,
                eventData2
            };

            CosmosDbThrottledEventsFilter cosmosDbThrottledEventsFilter = new CosmosDbThrottledEventsFilter();

            //Act
            IEnumerable <string> collections = cosmosDbThrottledEventsFilter.GetUniqueCosmosDbCollectionNamesFromEventData(events);

            //Assert
            collections
            .Should()
            .HaveCount(1);

            collections
            .First()
            .Should()
            .Be("calcs");
        }
        public void GetUniqueCosmosDBContainerNamesFromEventData_GivenEventsWhereOneStatusCodeIs429_ReturnsCollectionWithOneItem()
        {
            //Arrange
            EventData eventData1 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData1.Properties.Add("statusCode", (int)HttpStatusCode.Created);
            eventData1.Properties.Add("collection", "specs");

            EventData eventData2 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData2.Properties.Add("statusCode", (int)HttpStatusCode.TooManyRequests);
            eventData2.Properties.Add("collection", "calcs");

            IEnumerable <EventData> events = new[]
            {
                eventData1,
                eventData2
            };

            CosmosDbThrottledEventsFilter cosmosDbThrottledEventsFilter = new CosmosDbThrottledEventsFilter();

            //Act
            IEnumerable <string> collections = cosmosDbThrottledEventsFilter.GetUniqueCosmosDBContainerNamesFromEventData(events);

            //Assert
            collections
            .Should()
            .HaveCount(1);

            collections
            .First()
            .Should()
            .Be("calcs");
        }
        public void GetUniqueCosmosDbCollectionNamesFromEventData_GivenEventsWhereStatusCodeDoesNotExist_ReturnsEmptyCollections()
        {
            //Arrange
            EventData eventData1 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData1.Properties.Add("statusCode", 201);
            EventData eventData2 = new EventData(Encoding.UTF8.GetBytes(""));

            eventData2.Properties.Add("statusCode", 200);

            IEnumerable <EventData> events = new[]
            {
                eventData1,
                eventData2
            };

            CosmosDbThrottledEventsFilter cosmosDbThrottledEventsFilter = new CosmosDbThrottledEventsFilter();

            //Act
            IEnumerable <string> collections = cosmosDbThrottledEventsFilter.GetUniqueCosmosDbCollectionNamesFromEventData(events);

            //Assert
            collections
            .Should()
            .BeEmpty();
        }
        public void GetUniqueCosmosDBContainerNamesFromEventData_GivenEventsWhereStatusCodeDoesNotSupplied_ReturnsEmptyCollections()
        {
            //Arrange
            EventData eventData1 = new EventData(Encoding.UTF8.GetBytes(""));
            EventData eventData2 = new EventData(Encoding.UTF8.GetBytes(""));

            IEnumerable <EventData> events = new[]
            {
                eventData1,
                eventData2
            };

            CosmosDbThrottledEventsFilter cosmosDbThrottledEventsFilter = new CosmosDbThrottledEventsFilter();

            //Act
            IEnumerable <string> collections = cosmosDbThrottledEventsFilter.GetUniqueCosmosDBContainerNamesFromEventData(events);

            //Assert
            collections
            .Should()
            .BeNullOrEmpty();
        }