Exemple #1
0
        public async Task GetEventTypesHandler_Handle_ReturnAllEventTypes()
        {
            var eventTypeIndex = new Dictionary <long, EventType>();

            var eventTypeToFind = new EventType()
            {
                Id   = 5,
                Name = "Test Event Type"
            };
            var additionalEventType = new EventType()
            {
                Id   = 4,
                Name = "UnusedEventType"
            };

            if (!eventTypeIndex.TryAdd(eventTypeToFind.Id, eventTypeToFind))
            {
                throw new Exception("Test setup failure when populating dictionary");
            }
            if (!eventTypeIndex.TryAdd(additionalEventType.Id, additionalEventType))
            {
                throw new Exception("Test setup failure when populating dictionary");
            }

            var serviceUnderTest = new GetEventTypesHandler(eventTypeIndex);

            var request = new GetEventTypesRequest(null);
            var result  = await serviceUnderTest
                          .Handle(request, cancellationToken : new CancellationToken())
                          .ConfigureAwait(continueOnCapturedContext: false);

            Assert.AreEqual(eventTypeIndex.Values.ElementAt(0), result.ElementAt(0));
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonFraudDetectorConfig config = new AmazonFraudDetectorConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonFraudDetectorClient client = new AmazonFraudDetectorClient(creds, config);

            GetEventTypesResponse resp = new GetEventTypesResponse();

            do
            {
                GetEventTypesRequest req = new GetEventTypesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.GetEventTypes(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.EventTypes)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Exemple #3
0
        public async Task GetEventTypesHandler_Handle_WhenNoEventTypes_Return_Empty_Enumerable()
        {
            var eventTypeIndex   = new Dictionary <long, EventType>();
            var serviceUnderTest = new GetEventTypesHandler(eventTypeIndex);
            var request          = new GetEventTypesRequest(null);

            var result = await serviceUnderTest
                         .Handle(request, cancellationToken : new CancellationToken())
                         .ConfigureAwait(continueOnCapturedContext: false);

            Assert.AreEqual(0, result.Count());
        }