Beispiel #1
0
        public async Task WillNotSetLocation() {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));
            var ev = new PersistentEvent { Geo = GREEN_BAY_COORDINATES };
            await plugin.EventBatchProcessingAsync(new List<EventContext> { new EventContext(ev) });

            Assert.Equal(GREEN_BAY_COORDINATES, ev.Geo);
            Assert.Null(ev.GetLocation());
        }
Beispiel #2
0
        public async Task WillResetLocation(string geo) {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));
            
            var ev = new PersistentEvent { Geo = geo };
            await plugin.EventBatchProcessingAsync(new List<EventContext> { new EventContext(ev) });

            Assert.Null(ev.Geo);
            Assert.Null(ev.GetLocation());
        }
Beispiel #3
0
        public async Task WillSetLocationFromGeo() {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));
            var ev = new PersistentEvent { Geo = GREEN_BAY_IP };
            await plugin.EventBatchProcessingAsync(new List<EventContext> { new EventContext(ev) });

            Assert.NotNull(ev.Geo);
            Assert.NotEqual(GREEN_BAY_IP, ev.Geo);

            var location = ev.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);
        }
Beispiel #4
0
        public async Task WillSetMultipleFromEmptyGeo() {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));

            var ev = new PersistentEvent();
            var greenBayEvent = new PersistentEvent();
            greenBayEvent.SetEnvironmentInfo(new EnvironmentInfo { IpAddress = GREEN_BAY_IP });
            var irvingEvent = new PersistentEvent();
            irvingEvent.SetEnvironmentInfo(new EnvironmentInfo { IpAddress = IRVING_IP });
            await plugin.EventBatchProcessingAsync(new List<EventContext> {
                new EventContext(ev),
                new EventContext(greenBayEvent),
                new EventContext(irvingEvent)
            });

            Assert.Equal(GREEN_BAY_COORDINATES, greenBayEvent.Geo);
            var location = greenBayEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);

            Assert.Equal(IRVING_COORDINATES, irvingEvent.Geo);
            location = irvingEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("TX", location?.Level1);
            Assert.Equal("Irving", location?.Locality);
        }
Beispiel #5
0
        public async Task WillSetLocationFromEnvironmentInfoInfo() {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));
            var ev = new PersistentEvent();
            ev.SetEnvironmentInfo(new EnvironmentInfo { IpAddress = $"127.0.0.1,{GREEN_BAY_IP}" });
            await plugin.EventBatchProcessingAsync(new List<EventContext> { new EventContext(ev) });

            Assert.NotNull(ev.Geo);

            var location = ev.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);
        }
Beispiel #6
0
        public async Task WillSetLocationFromRequestInfo() {
            var plugin = new GeoPlugin(await GetResolverAsync());
            var ev = new PersistentEvent();
            ev.AddRequestInfo(new RequestInfo { ClientIpAddress = GREEN_BAY_IP });
            await plugin.EventBatchProcessingAsync(new List<EventContext> { new EventContext(ev) });

            Assert.NotNull(ev.Geo);

            var location = ev.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);
        }
Beispiel #7
0
        public async Task WillNotSetFromMultipleGeo() {
            var plugin = new GeoPlugin(await GetResolverAsync());

            var ev = new PersistentEvent();
            var greenBayEvent = new PersistentEvent { Geo = GREEN_BAY_IP };
            var irvingEvent = new PersistentEvent { Geo = IRVING_IP };
            await plugin.EventBatchProcessingAsync(new List<EventContext> {
                new EventContext(ev),
                new EventContext(greenBayEvent),
                new EventContext(irvingEvent)
            });

            Assert.Equal(GREEN_BAY_COORDINATES, greenBayEvent.Geo);
            var location = greenBayEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);

            Assert.Equal(IRVING_COORDINATES, irvingEvent.Geo);
            location = irvingEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("TX", location?.Level1);
            Assert.Equal("Irving", location?.Locality);
        }