public decimal EngineShouldCreateCorrectPayout(string wheelString, int level, int scatterMultiplier)
        {
            var config  = new Configuration();
            var spinBet = MainGameEngine.GenerateSpinBet(new RequestContext <SpinArgs>("", "", PlatformType.Web)
            {
                GameSetting = new Model.Entity.GameSetting {
                    GameSettingGroupId = 0
                },
                Currency = new Model.Entity.Currency {
                    Id = 0
                },
                Parameters = new SpinArgs
                {
                    LineBet    = 1,
                    Multiplier = 1
                }
            });

            var wheel        = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString);
            var winPositions = MainGameEngine.GenerateWinPositions(
                config.Payline,
                config.PayTable,
                wheel,
                spinBet.LineBet,
                spinBet.Lines,
                spinBet.Multiplier);

            var spinResult      = new Games.NuwaAndTheFiveElements.Models.GameResults.Spins.SpinResult(level, spinBet, wheel, null, winPositions, null, null);
            var instantWinBonus = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);

            instantWinBonus.UpdateBonus(scatterMultiplier);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            return(instantWinBonusResult.Win);
        }
        public void EngineShouldWriteXmlOfInstantWinResultXml(int gameId, int level)
        {
            var module               = GetModule(gameId);
            var spinResult           = GenerateWithBonusSpinResult(level);
            var instantWinBonus      = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinMultiplier = InstantWinBonusEngine.GetInstantWinMultiplier(module.Configuration.BonusConfig.InstantWin.MultiplierWeights[level]);

            instantWinBonus.UpdateBonus(instantWinMultiplier);

            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);
            var xElement = instantWinBonusResult.ToXElement();

            Assert.DoesNotThrow(() =>
            {
                var responseXml = new InstantWinXml();
                using (var xmlReader = xElement.CreateReader())
                {
                    responseXml.ReadXml(xmlReader);
                }

                using (var memStream = new MemoryStream())
                    using (var xmlWriter = XmlWriter.Create(memStream, new XmlWriterSettings()
                    {
                        ConformanceLevel = ConformanceLevel.Auto
                    }))
                    {
                        xmlWriter.WriteStartElement("bonus");
                        responseXml.WriteXml(xmlWriter);
                    }
            });
        }
        public void EngineShouldCompleteInstantWinBonusResultOnCreate(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            Assert.IsTrue(instantWinBonusResult.IsCompleted);
        }
        public void EngineShouldCreateInstantWinBonusResultWithSameSpinTransactionId(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            Assert.IsTrue(instantWinBonusResult.SpinTransactionId == instantWinBonus.SpinTransactionId);
        }
        public void EngineShouldCreateInstantWinBonusResultWithSameGameResultAndBonus(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            Assert.AreSame(instantWinBonusResult.Bonus, instantWinBonus);
        }
        public void EngineShouldCreateBonusResponseXmlOfInstantWinBonusResult(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            var responseXml = instantWinBonusResult.ToResponseXml(ResponseXmlFormat.History);

            Assert.IsNotNull(responseXml);
        }
        public void EngineShouldCreateBonusXElementOfInstantWinBonusResult(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            var xElement = instantWinBonusResult.ToXElement();

            Assert.IsNotNull(xElement);
        }
        public void EngineShouldCreateBonusResponseXmlOfInstantWinResult(int gameId, int level)
        {
            var module               = GetModule(gameId);
            var spinResult           = GenerateWithBonusSpinResult(level);
            var instantWinBonus      = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinMultiplier = InstantWinBonusEngine.GetInstantWinMultiplier(module.Configuration.BonusConfig.InstantWin.MultiplierWeights[level]);

            instantWinBonus.UpdateBonus(instantWinMultiplier);

            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);
            var responseXml           = instantWinBonusResult.ToResponseXml(ResponseXmlFormat.History);

            Assert.IsNotNull(responseXml);
        }
        public void EngineShouldCreateBonusXElementOfInstantWinResult(int gameId, int level)
        {
            var module               = GetModule(gameId);
            var spinResult           = GenerateWithBonusSpinResult(level);
            var instantWinBonus      = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinMultiplier = InstantWinBonusEngine.GetInstantWinMultiplier(module.Configuration.BonusConfig.InstantWin.MultiplierWeights[level]);

            instantWinBonus.UpdateBonus(instantWinMultiplier);

            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);
            var xElement = instantWinBonusResult.ToXElement();

            Assert.IsNotNull(xElement);
        }
        public void EngineShouldReadResponseXmlOfInstantBonusResult(int level)
        {
            var config                = new Configuration();
            var spinResult            = GenerateWithBonusSpinResult(level);
            var instantWinBonus       = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);

            var xElement = instantWinBonusResult.ToXElement();

            Assert.DoesNotThrow(() =>
            {
                using (var xmlReader = xElement.CreateReader())
                {
                    var responseXml = new BonusXml();
                    responseXml.ReadXml(xmlReader);
                }
            });
        }
        public void EngineShouldReadResponseXmlOfInstantWinResult(int gameId, int level)
        {
            var module               = GetModule(gameId);
            var spinResult           = GenerateWithBonusSpinResult(level);
            var instantWinBonus      = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinMultiplier = InstantWinBonusEngine.GetInstantWinMultiplier(module.Configuration.BonusConfig.InstantWin.MultiplierWeights[level]);

            instantWinBonus.UpdateBonus(instantWinMultiplier);

            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);
            var xElement = instantWinBonusResult.ToXElement();

            Assert.DoesNotThrow(() =>
            {
                using (var xmlReader = xElement.CreateReader())
                {
                    var responseXml = new InstantWinXml();
                    responseXml.ReadXml(xmlReader);
                }
            });
        }
        public void EngineShouldCopyBonusValuesFromResultToXml(int gameId, int level)
        {
            var module               = GetModule(gameId);
            var spinResult           = GenerateWithBonusSpinResult(level);
            var instantWinBonus      = InstantWinBonusEngine.CreateInstantWinBonus(spinResult);
            var instantWinMultiplier = InstantWinBonusEngine.GetInstantWinMultiplier(module.Configuration.BonusConfig.InstantWin.MultiplierWeights[level]);

            instantWinBonus.UpdateBonus(instantWinMultiplier);

            var instantWinBonusResult = InstantWinBonusEngine.CreateInstantWinBonusResult(instantWinBonus);
            var xElement    = instantWinBonusResult.ToXElement();
            var responseXml = new InstantWinXml();

            using (var xmlReader = xElement.CreateReader())
            {
                responseXml.ReadXml(xmlReader);
            }

            Assert.IsNull(responseXml.GetSchema());
            Assert.AreEqual(instantWinBonusResult.Win, responseXml.Win);
        }