Beispiel #1
0
        public void TestAuctionsQueens(string testName, string northHand, string southHand, string expectedBidsNorth, string expectedBidsSouth)
        {
            // This test can fail because it relies on the sampling and dds.
            if (testName is null)
            {
                throw new ArgumentNullException(nameof(testName));
            }
            logger.Info($"Executing testcase {testName}");

            _ = Pinvoke.Setup("Tosr.db3");
            var bidManager      = new BidManager(new BidGenerator(), fasesWithOffset, reverseDictionaries, true, false);
            var auction         = bidManager.GetAuction(northHand, southHand);
            var actualBidsSouth = auction.GetBidsAsString(Player.South);

            Assert.Equal(expectedBidsSouth, actualBidsSouth);

            var actualBidsNorth = auction.GetBidsAsString(Player.North);

            Assert.Equal(expectedBidsNorth, actualBidsNorth);

            var constructedSouthHand = bidManager.biddingInformation.ConstructSouthHand(northHand);

            Assert.Equal(Util.HandWithx(southHand), constructedSouthHand.First());

            var queens = bidManager.biddingInformation.GetQueensFromAuction(auction, reverseDictionaries);

            Assert.True(BiddingInformation.CheckQueens(queens, southHand));
        }
        public void ExecuteTest()
        {
            var bidGenerator    = new Mock <IBidGenerator>();
            var fasesWithOffset = JsonConvert.DeserializeObject <Dictionary <Fase, bool> >(File.ReadAllText("FasesWithOffset.json"));

            // 1Sp
            bidGenerator.SetupSequence(x => x.GetBid(It.IsAny <BiddingState>(), It.IsAny <string>())).
            // 1Sp
            Returns(() => (4, Fase.Shape, "")).
            // 2Di
            Returns(() => (7, Fase.Shape, "")).
            // 3NT
            Returns(() => (15, Fase.Controls, "")).
            // 4NT
            Returns(() => (5, Fase.Scanning, "")).
            // 5NT
            Returns(() => (5, Fase.Scanning, "")).
            // Pass
            Returns(() => (0, Fase.Scanning, ""));

            var auction = BidManager.GetAuction("", bidGenerator.Object, fasesWithOffset);

            Assert.Equal("1♣1NT2♥4♣5♦6♥", auction.GetBidsAsString(Player.North));
            Assert.Equal("1♠2♦3NT5♣6♦Pass", auction.GetBidsAsString(Player.South));
            Assert.Equal("1♠2♦3NT", auction.GetBidsAsString(Player.South, x => x.Value[Player.South].fase == Fase.Shape));
            Assert.Equal("5♣", auction.GetBidsAsString(Player.South, x => x.Value[Player.South].fase == Fase.Controls));
            Assert.Equal("6♦", auction.GetBidsAsString(Player.South, x => x.Value[Player.South].fase == Fase.Scanning));
        }
Beispiel #3
0
        public void TestAuctions4Diamond(string testName, string northHand, string southHand, string expectedBidsNorth, string expectedBidsSouth)
        {
            SetupTest.setupTest(testName, logger);
            var bidManager = new BidManager(new BidGeneratorDescription(), fasesWithOffset, reverseDictionaries, (auction, northHand, sourceInformation) => { return(BidManager.RelayBidKind.fourDiamondEndSignal); });
            var auction    = bidManager.GetAuction(northHand, southHand);

            AssertMethods.AssertAuction(expectedBidsNorth, expectedBidsSouth, auction);
        }
Beispiel #4
0
        public void TestAuctions3NT(string testName, string northHand, string southHand, string expectedBidsNorth, string expectedBidsSouth)
        {
            SetupTest.setupTest(testName, logger);
            var bidManager = new BidManager(new BidGeneratorDescription(), fasesWithOffset, reverseDictionaries, false);
            var auction    = bidManager.GetAuction(northHand, southHand);

            AssertMethods.AssertAuction(expectedBidsNorth, expectedBidsSouth, auction);
        }
        public static void ExecuteTest()
        {
            var fasesWithOffset   = JsonConvert.DeserializeObject <Dictionary <Fase, bool> >(File.ReadAllText("FasesWithOffset.json"));
            var bidGenerator      = new BidGenerator();
            var expectedSouthBids = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText("expectedSouthBidsPerHand.json"));

            Pinvoke.Setup("Tosr.db3");
            foreach (var(hand, expectedBids) in expectedSouthBids)
            {
                var generatedAuction   = BidManager.GetAuction(hand, bidGenerator, fasesWithOffset);
                var generatedSouthBids = generatedAuction.GetBidsAsString(Player.South);
                Assert.Equal(expectedBids, generatedSouthBids);
            }
        }
Beispiel #6
0
        public void BidTest()
        {
            var bidManager = new BidManager();
            var pbn        = new Pbn();

            foreach (var pbnFile in Directory.GetFiles("..\\..\\..\\..\\Wpf.BidTrainer\\Pbn", "*.pbn"))
            {
                pbn.Load(pbnFile);
                foreach (var board in pbn.Boards)
                {
                    board.Auction = bidManager.GetAuction(board.Deal, board.Dealer);
                }

                var filePath = $"{pbnFile}.{DateTime.Now.ToShortDateString()}";
                pbn.Save(filePath);
                Assert.Equal(File.ReadAllText($"{pbnFile}.etalon"), File.ReadAllText(filePath));
            }
        }