public void TestReSpinFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 32);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 10,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneKoi", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneKoiBonus {
                SpinBet = bet
            });
            var state = new ReSpinState(new List <int[]>
            {
                new int[] { },
                new int[] { 7, 7, 7 },
                new int[] { },
                new int[] { },
                new int[] { }
            }, new bool[] { false, true, false, false, false });

            //Action
            var response    = state.Handle(requestBonusContext, bonusContext);
            var result      = response.result;
            var responseXml = xmlhelper.Serialize(result.ToResponseXml(ResponseXmlFormat.None));
            var element     = XElement.Parse(responseXml, LoadOptions.PreserveWhitespace);

            // Assert
            Assert.IsNotNull(element);
            Assert.IsTrue(element.Element("data").Element("spin").Element("wheels") != null);
            Assert.AreEqual(result.Win, decimal.Parse(element.Element("win").Value));
            Assert.AreEqual(result.Win > 0, element.Element("data").Element("spin").Element("winposition").Descendants().Count() > 0);
            if (result.SpinResult.HasBonus)
            {
                Assert.IsNotNull(element.Element("data").Element("spin").Element("bonus"));
                Assert.IsTrue(string.IsNullOrEmpty(element.Element("data").Element("spin").Element("bonusposition").Value) == false);
                Assert.IsNotNull(element.Element("data").Element("spin").Element("bonusposition"));
                Assert.IsTrue(element.Element("data").Element("spin").Element("bonusposition").Descendants().Count() > 0);
            }
        }
Пример #2
0
        public void TestExplodingFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 109);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneChimes", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneChimesBonus {
                SpinBet = bet
            });
            var bonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    RowPositions = new List <int> {
                        1, 1, 1, 0, 0
                    }
                }
            };
            var wheel = new FortuneChimesWheel
            {
                Reels = new List <int[]> {
                    new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { -1, -1, -1 }, new[] { -1, -1, -1 }
                },
                Indices = new int[] { 1, 2, 3, 4, 5 }
            };
            var reSpinCollapse = new ReSpinCollapse(bonusPositions, wheel, new List <int[]> {
                new int[0], new int[0], new int[0], new int[] { -1, -2, -3 }, new int[] { -1, -2, -3 }
            });
            var state = new ReSpinState(reSpinCollapse);

            //Action
            var response = state.Handle(requestBonusContext, bonusContext);

            // Assert
            Assert.AreEqual(response.result.Win > 0, response.nextState is ReSpinState);
            Assert.AreEqual(response.result.Win > 0, !response.nextState.IsCompleted);
            Assert.AreEqual(response.result.Win == 0, response.nextState is Finish);
        }
Пример #3
0
        public void TestReSpinFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 32);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 10,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneKoi", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneKoiBonus {
                SpinBet = bet
            });
            var state = new ReSpinState(new List <int[]> {
                new [] { 0, 1, 2 },
                new [] { 0, 7, 1 },
                new [] { 4, 5, 6 },
                new [] { 1, 2, 3 },
                new [] { 6, 5, 4 }
            },
                                        new bool[] { false, true, false, false, false });

            //Action
            var response   = state.Handle(requestBonusContext, bonusContext);
            var spinResult = response.result.SpinResult;
            var wheel      = spinResult.Wheel;

            // Assert
            Assert.AreEqual(spinResult.HasBonus, !response.nextState.IsCompleted);
            Assert.AreEqual(wheel[2].Any(item => item == 7) || wheel[3].Any(item => item == 7), response.nextState is ReSpinState);
            Assert.AreEqual(wheel[2].All(item => item < 7) && wheel[3].All(item => item < 7), response.nextState is Finish);
        }
Пример #4
0
        public void TestReSpinCollapseFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 109);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "Fortune Chimes", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneChimesBonus {
                SpinBet = bet
            });
            var bonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    Line = 1, RowPositions = new List <int> {
                        1, 1, 1, 0, 0
                    }
                }
            };
            var wheel = new FortuneChimesWheel
            {
                Reels = new List <int[]> {
                    new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { -1, -1, -1 }, new[] { -1, -1, -1 }
                },
                Indices = new int[] { 1, 2, 3, 4, 5 }
            };
            var state = new ReSpinState(new ReSpinCollapse(bonusPositions, wheel, new List <int[]> {
                new int[0], new int[0], new int[0], new int[] { 1, 2, 4 }, new int[] { 2, 5, 7 }
            }));

            //Action
            var response    = state.Handle(requestBonusContext, bonusContext);
            var result      = response.result;
            var instanceWin = result.SpinResult.InstanceWin;
            var responseXml = xmlhelper.Serialize(result.ToResponseXml(ResponseXmlFormat.None));
            var element     = XElement.Parse(responseXml, LoadOptions.PreserveWhitespace);

            // Assert
            Assert.IsNotNull(element);
            Assert.IsTrue(element.Element("data").Element("spin").Element("wheels") != null);
            Assert.AreEqual(result.Win, decimal.Parse(element.Element("win").Value));
            Assert.AreEqual(result.Win > 0, element.Element("data").Element("spin").Element("winposition").Descendants().Count() > 0);
            Assert.AreEqual(result.SpinResult.HasBonus, !string.IsNullOrEmpty(element.Element("data").Element("spin").Element("bonus").Value));
            Assert.AreEqual(result.SpinResult.HasBonus, element.Element("data").Element("spin").Element("bonusposition").Descendants().Count() > 0);
            Assert.AreEqual(instanceWin != null, element.Element("data").Element("spin").Element("iw").HasAttributes);
        }