public void IsIgnored_DoesNotIgnorePokemonIgnoredInFirstAreaButNotSecond()
        {
            // Arrange
            var options = GetOptions(new[]
            {
                new NotificationAreaOptions
                {
                    Pokemon = new[] { new IgnoredPokemon {
                                          Ignore = true, Id = PokemonId1
                                      } },
                    Polygon = GetSmallRectanglePoints()
                },
                new NotificationAreaOptions
                {
                    Pokemon = new[] { new IgnoredPokemon {
                                          Ignore = false, Id = PokemonId1
                                      } },
                    Polygon = GetLargeRectanglePoints()
                },
            });
            var encounter = GetEncounterInBothRectangles(PokemonId1);
            var target    = new IgnoredPokemonService(options);

            // Act
            var ignored = target.IsIgnored(encounter);

            // Assert
            Assert.False(ignored);
        }
        public void IsIgnored_IgnoresPokemonIgnoredInFirstAreaButNotMentionedAndNotInSecondArea()
        {
            // Arrange
            var options = GetOptions(new[]
            {
                new NotificationAreaOptions
                {
                    Pokemon = new[] { new IgnoredPokemon {
                                          Ignore = true, Id = PokemonId1
                                      } },
                    Polygon = GetLargeRectanglePoints()
                },
                new NotificationAreaOptions
                {
                    Pokemon = new IgnoredPokemon[0],
                    Polygon = GetSmallRectanglePoints()
                },
            });
            var encounter = GetEncounterOnlyInLargeRectangle(PokemonId1);
            var target    = new IgnoredPokemonService(options);

            // Act
            var ignored = target.IsIgnored(encounter);

            // Assert
            Assert.True(ignored);
        }
示例#3
0
 private static void AssertIgnored(IgnoredPokemonService target, PokemonEncounter encounter, bool ignored, string name, string label)
 {
     if (ignored)
     {
         Assert.True(target.IsIgnored(encounter), $"{name} should be ignored {label}.");
     }
     else
     {
         Assert.False(target.IsIgnored(encounter), $"{name} should not be ignored {label}.");
     }
 }
        public void IsIgnored_DoesNotIgnoreWhentThereAreNoAreas()
        {
            // Arrange
            var options   = GetOptions(Enumerable.Empty <NotificationAreaOptions>());
            var encounter = GetEncounterInBothRectangles(PokemonId1);
            var target    = new IgnoredPokemonService(options);

            // Act
            var ignored = target.IsIgnored(encounter);

            // Assert
            Assert.False(ignored);
        }
示例#5
0
        public void Sandbox(int id, string name, bool ignoredInSmallestArea, bool ignoredElsewhere)
        {
            // Arrange
            var notificationOptions = GetWebsiteNotificationOptions("dev");
            var testOptions         = Configuration.TestOptions;
            var target = new IgnoredPokemonService(Options.Create(notificationOptions));

            var insideSmallestArea  = CreateEncounter(id, testOptions.PointInsideSmallestArea);
            var outsideSmallestArea = CreateEncounter(id, testOptions.PointOutsideSmallestArea);
            var farAway             = CreateEncounter(id, testOptions.FarAwayPoint);

            // Act & Assert
            if (ignoredInSmallestArea)
            {
                Assert.True(ignoredElsewhere, $"{name} is ignored in the smallest area but not elsewhere. That doesn't make sense.");
            }

            AssertIgnored(target, insideSmallestArea, ignoredInSmallestArea, name, "in the smallest area");
            AssertIgnored(target, outsideSmallestArea, ignoredElsewhere, name, "outside the smallest area");
            AssertIgnored(target, farAway, ignoredElsewhere, name, "far away");
        }
        public void IsIgnored_IgnoresPokemonInIgnoredList()
        {
            // Arrange
            var options = GetOptions(new[]
            {
                new NotificationAreaOptions
                {
                    Pokemon = new[] { new IgnoredPokemon {
                                          Ignore = true, Id = PokemonId1
                                      } },
                    Polygon = GetSmallRectanglePoints()
                }
            });
            var encounter = GetEncounterInBothRectangles(PokemonId1);
            var target    = new IgnoredPokemonService(options);

            // Act
            var ignored = target.IsIgnored(encounter);

            // Assert
            Assert.True(ignored);
        }