示例#1
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_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);
        }
        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);
        }
        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);
        }