public void TryBuildTest(string testFolder)
        {
            HandHistory actual = null;

            using (ShimsContext.Create())
            {
                ShimDateTime.UtcNowGet = () => handDate;

                var packages = ReadPackages(testFolder);

                CollectionAssert.IsNotEmpty(packages, $"Packages collection must be not empty for {testFolder}");

                var handBuilder = new Adda52HandBuilder();

                foreach (var package in packages)
                {
                    if (handBuilder.TryBuild(package, out actual))
                    {
                        break;
                    }
                }
            }

            Assert.IsNotNull(actual, $"Actual HandHistory must be not null for {testFolder}");

            var expected = ReadExpectedHandHistory(testFolder);

            Assert.IsNotNull(expected, $"Expected HandHistory must be not null for {testFolder}");

            AssertionUtils.AssertHandHistory(actual, expected);
        }
Esempio n. 2
0
        public void TryBuildTest(string testFolder, uint heroId)
        {
            var packages = ReadPackages(testFolder);

            CollectionAssert.IsNotEmpty(packages, $"Packages collection must be not empty for {testFolder}");

            var handBuilder = new PKHandBuilder();

            HandHistory actual = null;

            foreach (var package in packages)
            {
                package.UserId = heroId;

                if (handBuilder.TryBuild(package, identifier, out actual))
                {
                    break;
                }
            }

            Assert.IsNotNull(actual, $"Actual HandHistory must be not null for {testFolder}");

            var expected = ReadExpectedHandHistory(testFolder);

            Assert.IsNotNull(expected, $"Expected HandHistory must be not null for {testFolder}");

            AssertionUtils.AssertHandHistory(actual, expected);
        }
Esempio n. 3
0
        public void TryBuildTest(string testFolder)
        {
            var packages = ReadPackages(testFolder);

            CollectionAssert.IsNotEmpty(packages, $"Packages collection must be not empty for {testFolder}");

            var handBuilder = new PokerBaaziHandBuilder();

            HandHistory actual = null;

            foreach (var package in packages.Where(x => x.PackageType != PokerBaaziPackageType.Unknown))
            {
                if (handBuilder.TryBuild(package, out actual, out PokerBaaziHandBuilderError error))
                {
                    break;
                }
            }

            Assert.IsNotNull(actual, $"Actual HandHistory must be not null for {testFolder}");

            var expected = ReadExpectedHandHistory(testFolder);

            Assert.IsNotNull(expected, $"Expected HandHistory must be not null for {testFolder}");

            AssertionUtils.AssertHandHistory(actual, expected);
        }
        public void TryBuildTest(string testFolder)
        {
            var packages = ReadPackages(testFolder);

            CollectionAssert.IsNotEmpty(packages, $"Packages collection must be not empty for {testFolder}");

            var handBuilder = new PPPHandBuilder();

            HandHistory actual = null;

            if (testFolder == NlheSngTest)
            {
                using (ShimsContext.Create())
                {
                    ShimDateTime.UtcNowGet = () => new DateTime(2018, 10, 11, 17, 07, 14);

                    Build(handBuilder, packages, out actual);
                }
            }
            else
            {
                Build(handBuilder, packages, out actual);
            }


            Assert.IsNotNull(actual, $"Actual HandHistory must be not null for {testFolder}");

            var expected = ReadExpectedHandHistory(testFolder);

            Assert.IsNotNull(expected, $"Expected HandHistory must be not null for {testFolder}");

            AssertionUtils.AssertHandHistory(actual, expected);
        }
Esempio n. 5
0
        public void TestClone(string fileName)
        {
            var handHistory = ReadHandHistory(fileName);

            var handHistoryClone = handHistory.DeepClone();

            AssertionUtils.AssertHandHistory(handHistory, handHistoryClone);
        }
Esempio n. 6
0
        public void TryBuildTest(string dataFolder, long heroId, bool isStringEnum)
        {
            var jsonTestData = GetJsonFileFromFolder(dataFolder, isStringEnum);

            var handBuilder = new HandBuilder();

            var         result = false;
            HandHistory actual = null;

            foreach (var gameRoomStateChange in jsonTestData.GameRoomStateChanges)
            {
                var res = JsonConvert.SerializeObject(gameRoomStateChange, new StringEnumConverter());

                foreach (var c in gameRoomStateChange.GameRoomInfo.UserGameInfos)
                {
                    if (!c.IsActive)
                    {
                        continue;
                    }

                    Console.WriteLine($"{c.GameState}, {c.UserInfo.Nick}: {DateTimeHelper.UnixTimeToDateTime(c.ActTime / 1000)}");
                }

                result = handBuilder.TryBuild(gameRoomStateChange, heroId, out actual);

                if (result)
                {
                    break;
                }
            }

            Assert.IsTrue(result, "Result must be true");
            Assert.IsNotNull(actual, "Hand history must be built as a result.");

            AssertionUtils.AssertHandHistory(actual, jsonTestData.ExpectedResult);
        }