public void GetInfobox_WikiTextIsPoliceStation_ShouldReturnCorrectResult()
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(testDataPoliceStation);

            // Assert
            //Old World
            Assert.Equal("Police Station", result[0].Name);
            Assert.Equal(BuildingType.Institution, result[0].Type);
            Assert.Null(result[0].ProductionInfos);
            Assert.Null(result[0].SupplyInfos);

            Assert.Equal(WorldRegion.OldWorld, result[0].Region);
            Assert.Single(result[0].UnlockInfos.UnlockConditions);
            Assert.Equal(500, result[0].UnlockInfos.UnlockConditions[0].Amount);
            Assert.Equal("Workers", result[0].UnlockInfos.UnlockConditions[0].Type);

            //New World
            Assert.Equal("Police Station", result[1].Name);
            Assert.Equal(BuildingType.Institution, result[1].Type);
            Assert.Null(result[1].ProductionInfos);
            Assert.Null(result[1].SupplyInfos);

            Assert.Equal(WorldRegion.NewWorld, result[1].Region);
            Assert.Single(result[1].UnlockInfos.UnlockConditions);
            Assert.Equal(0, result[1].UnlockInfos.UnlockConditions[0].Amount);
            Assert.Equal("Jornaleros", result[1].UnlockInfos.UnlockConditions[0].Type);
        }
        public void GetInfobox_SupplyTypeCounterIsNotParseable_ShouldThrow()
        {
            // Arrange
            var input = $"|Supplies {int.MaxValue + 1L} Type (OW) = Farmer";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act/Assert
            var ex = Assert.Throws <Exception>(() => parser.GetInfobox(input));
        }
        public void GetInfobox_InputIconCounterIsNotParseable_ShouldThrow()
        {
            // Arrange
            var input = $"|Produces Amount (OW) = 1{Environment.NewLine}|Input {int.MaxValue + 1L} Icon (OW) = dummy.png";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act/Assert
            var ex = Assert.Throws <Exception>(() => parser.GetInfobox(input));
        }
        public void GetInfobox_UnlockAmountIsNotParseable_ShouldThrow()
        {
            // Arrange
            var input = $"|Unlock Condition 1 Amount (OW) = {double.MaxValue.ToString()}";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act/Assert
            var ex = Assert.Throws <Exception>(() => parser.GetInfobox(input));
        }
        public void GetInfobox_SupplyAmountElectricityIsNotParseable_ShouldThrow()
        {
            // Arrange
            var input = $"|Supplies 1 Amount Electricity (OW) = {double.MaxValue.ToString()}";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act/Assert
            var ex = Assert.Throws <Exception>(() => parser.GetInfobox(input));
        }
        public void GetInfobox_UnlockAmountCounterIsNotParseable_ShouldThrow()
        {
            // Arrange
            var input = $"|Unlock Condition {int.MaxValue + 1L} Amount (OW) = 42";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act/Assert
            var ex = Assert.Throws <Exception>(() => parser.GetInfobox(input));
        }
        public void GetInfobox_WikiTextIsNullOrWhiteSpace_ShouldReturnNull(string input)
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Null(result);
        }
        public void GetInfobox_WikiTextContainsNoUnlockInfo_ShouldReturnCorrectValue()
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(testDataEmpty_BothWorlds);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Null(result[0].UnlockInfos);
            Assert.Null(result[1].UnlockInfos);
        }
        public void GetInfobox_WikiTextContainsSpecialTitle_ShouldReturnCorrectValue(string input, string expectedName)
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(expectedName, result[0].Name);
            Assert.Equal(expectedName, result[1].Name);
        }
        public void GetInfobox_WikiTextContainsNoTitle_ShouldReturnEmpty()
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox("dummy");

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(string.Empty, result[0].Name);
            Assert.Equal(string.Empty, result[1].Name);
        }
        public void GetInfobox_WikiTextContainsBuildingTypeDifferentCasing_ShouldReturnCorrectValue(string input, BuildingType expectedType)
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(expectedType, result[0].Type);
            Assert.Equal(expectedType, result[1].Type);
        }
        public void GetInfobox_WikiTextContainsBuildingTypeNewWorld_ShouldReturnCorrectValue(string input, BuildingType expectedType)
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(BuildingType.Unknown, result.Single(x => x.Region == WorldRegion.OldWorld).Type);
            Assert.Equal(expectedType, result.Single(x => x.Region == WorldRegion.NewWorld).Type);
        }
        public void GetInfobox_WikiTextContainsUnknownBuildingType_ShouldReturnUnknown(string input)
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(BuildingType.Unknown, result[0].Type);
            Assert.Equal(BuildingType.Unknown, result[1].Type);
        }
        public void GetInfobox_ProducesAmountIsDouble_ShouldSetAmount()
        {
            // Arrange
            var input = "|Produces Amount (OW) = 42,21";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(42.21, result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.EndProduct.Amount);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_WikiTextContainsProductionAmountAndWhiteSpace_ShouldReturnCorrectValue()
        {
            // Arrange
            var input = "|Produces Amount   (OW)   =    42    ";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(42, result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.EndProduct.Amount);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_ProducesIconIsPresentAndWhiteSpace_ShouldSetIcon()
        {
            // Arrange
            var input = $"|Produces Icon  (OW)  =     dummy.png  {Environment.NewLine}|Produces Amount (OW)";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal("dummy.png", result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.EndProduct.Icon);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_WikiTextContainsUnlockTypeAndWhiteSpace_ShouldReturnCorrectValue()
        {
            // Arrange
            var input = "|Unlock Condition 1 Type (OW)  =   Workers     ";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Single(result.Single(x => x.Region == WorldRegion.OldWorld).UnlockInfos.UnlockConditions);
            Assert.Equal("Workers", result.Single(x => x.Region == WorldRegion.OldWorld).UnlockInfos.UnlockConditions[0].Type);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).UnlockInfos);
        }
        public void GetInfobox_ProducesAmountIsNotParseable_ShouldNotSetAmount()
        {
            // Arrange
            var input = "|Produces Amount (OW) = no_number" + Environment.NewLine + "|Produces Amount Electricity (OW) = 1";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(0, result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.EndProduct.Amount);
            Assert.Equal(1, result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.EndProduct.AmountElectricity);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_WikiTextContainsInputAmountElectricity_ShouldReturnCorrectValue()
        {
            // Arrange
            var input = $"|Produces Amount{Environment.NewLine}|Input 1 Amount Electricity (OW) = 42";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Single(result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.InputProducts);
            Assert.Equal(42, result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.InputProducts[0].AmountElectricity);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_WikiTextContainsInputIconAndWhiteSpace_ShouldReturnCorrectValue()
        {
            // Arrange
            var input = $"|Produces Amount{Environment.NewLine}|Input 1 Icon  (OW)   =     dummy.png        ";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Single(result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.InputProducts);
            Assert.Equal("dummy.png", result.Single(x => x.Region == WorldRegion.OldWorld).ProductionInfos.InputProducts[0].Icon);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).ProductionInfos);
        }
        public void GetInfobox_WikiTextContainsSupplyAmountType_ShouldReturnCorrectValue()
        {
            // Arrange
            var input = "|Supplies 1 Type (OW) = Workers";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Single(result.Single(x => x.Region == WorldRegion.OldWorld).SupplyInfos.SupplyEntries);
            Assert.Equal("Workers", result.Single(x => x.Region == WorldRegion.OldWorld).SupplyInfos.SupplyEntries[0].Type);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).SupplyInfos);
        }
        public void GetInfobox_WikiTextContainsMultipleUnlockInfos_ShouldReturnCorrectOrderedValue()
        {
            // Arrange
            var input = $"|Unlock Condition 2 Amount (OW) = 21{Environment.NewLine}|Unlock Condition 1 Amount (OW) = 42";

            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(input);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Equal(2, result.Single(x => x.Region == WorldRegion.OldWorld).UnlockInfos.UnlockConditions.Count);
            Assert.Equal(42, result.Single(x => x.Region == WorldRegion.OldWorld).UnlockInfos.UnlockConditions[0].Amount);
            Assert.Equal(21, result.Single(x => x.Region == WorldRegion.OldWorld).UnlockInfos.UnlockConditions[1].Amount);
            Assert.Null(result.Single(x => x.Region == WorldRegion.NewWorld).UnlockInfos);
        }
        public void GetInfobox_WikiTextIsBrickFactory_ShouldReturnCorrectResult()
        {
            // Arrange
            var parser = new ParserBothWorlds(mockedCommons);

            // Act
            var result = parser.GetInfobox(testDataBrickFactory);

            // Assert
            //Old World
            Assert.Equal("Brick Factory", result[0].Name);
            Assert.Equal(BuildingType.Production, result[0].Type);
            Assert.NotNull(result[0].ProductionInfos);
            Assert.NotNull(result[0].ProductionInfos.EndProduct);
            Assert.Equal(1, result[0].ProductionInfos.EndProduct.Amount);
            Assert.Equal(2, result[0].ProductionInfos.EndProduct.AmountElectricity);
            Assert.Equal("Bricks.png", result[0].ProductionInfos.EndProduct.Icon);
            Assert.Single(result[0].ProductionInfos.InputProducts);
            Assert.Equal(1, result[0].ProductionInfos.InputProducts[0].Amount);
            Assert.Equal(2, result[0].ProductionInfos.InputProducts[0].AmountElectricity);
            Assert.Equal("Clay.png", result[0].ProductionInfos.InputProducts[0].Icon);
            Assert.Null(result[0].SupplyInfos);
            Assert.Equal(WorldRegion.OldWorld, result[0].Region);
            Assert.Single(result[0].UnlockInfos.UnlockConditions);
            Assert.Equal(1, result[0].UnlockInfos.UnlockConditions[0].Amount);
            Assert.Equal("Workers", result[0].UnlockInfos.UnlockConditions[0].Type);

            //New World
            Assert.Equal("Brick Factory", result[1].Name);
            Assert.Equal(BuildingType.Production, result[1].Type);
            Assert.NotNull(result[1].ProductionInfos);
            Assert.NotNull(result[1].ProductionInfos.EndProduct);
            Assert.Equal(1, result[1].ProductionInfos.EndProduct.Amount);
            Assert.Equal(0, result[1].ProductionInfos.EndProduct.AmountElectricity);
            Assert.Equal("Bricks.png", result[1].ProductionInfos.EndProduct.Icon);
            Assert.Single(result[1].ProductionInfos.InputProducts);
            Assert.Equal(1, result[1].ProductionInfos.InputProducts[0].Amount);
            Assert.Equal(0, result[1].ProductionInfos.InputProducts[0].AmountElectricity);
            Assert.Equal("Clay.png", result[1].ProductionInfos.InputProducts[0].Icon);
            Assert.Null(result[1].SupplyInfos);
            Assert.Equal(WorldRegion.NewWorld, result[1].Region);
            Assert.Single(result[1].UnlockInfos.UnlockConditions);
            Assert.Equal(1, result[1].UnlockInfos.UnlockConditions[0].Amount);
            Assert.Equal("Obreros", result[1].UnlockInfos.UnlockConditions[0].Type);
        }