Ejemplo n.º 1
0
 public void Play()
 {
     this.writer.Start(Message.Instance.Start());
     Hands.Unicode player = HandMaker.Instance.Random();
     Hands.Unicode npc    = HandMaker.Instance.Random();
     this.writer.Hand(Message.Instance.Hand(player, npc));
     Rule.Result result = Rule.Instance.Judge(player, npc);
     this.writer.Result(Message.Instance.Result(result));
 }
        public void Judge_vs2_ReturnResult(Hands.Unicode player, Hands.Unicode npc, Rule.Result playerResult, Rule.Result npcResult)
        {
            var input = new List <Hands.Unicode>()
            {
                player, npc
            };
            var actual   = Rule.Instance.Judge(input);
            var expected = new List <Rule.Result>()
            {
                playerResult, npcResult
            };

            Assert.That(expected, Is.EqualTo(actual));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns whether there is sufficient disk space quota for the requested space.
        /// </summary>
        /// <param name="space">Amount of space requested.</param>
        /// <returns>True if the requested space is under the quota limit. Otherwise false is returned.</returns>
        public bool Allowed(long space)
        {
            bool hasSpace = true;

            // Check the overall domain/member policy first to make sure that there
            // is space available.
            if (memberPolicy != null)
            {
                // Apply the rule to see if there is space available.
                Rule.Result result = memberPolicy.Apply(usedDiskSpace + space, DiskSpaceQuotaPolicyID);
                if (result == Rule.Result.Allow)
                {
                    // If there is a collection policy, let it update the
                    // used disk space.
                    if (collectionPolicy == null)
                    {
                        // Update the snapshot.
                        usedDiskSpace += space;
                    }
                }
                else
                {
                    hasSpace = false;
                }
            }

            // See if there is a collection policy that limits the amount of data
            // in the collection.
            if ((collectionPolicy != null) && (hasSpace == true))
            {
                // Apply the rule to see if there is space available in the collection.
                Rule.Result result = collectionPolicy.Apply(collectionSpace + space, null);
                if (result == Rule.Result.Allow)
                {
                    usedDiskSpace   += space;
                    collectionSpace += space;
                }
                else
                {
                    hasSpace = false;
                }
            }

            return(hasSpace);
        }
Ejemplo n.º 4
0
 /// <summary>勝敗メッセージを返す</summary>
 /// <param name="result">勝敗</param>
 /// <returns>勝敗メッセージ</returns>
 public string Result(Rule.Result result)
 {
     if (result == Rule.Result.Draw)
     {
         return("Draw");
     }
     else if (result == Rule.Result.Win)
     {
         return("Win!");
     }
     else if (result == Rule.Result.Lose)
     {
         return("Lose...");
     }
     else
     {
         throw new Exception("Not Exist Rule.Result");
     }
 }
        public void Judge_vs3_ReturnResult(Hands.Unicode p1, Hands.Unicode p2, Hands.Unicode p3, Rule.Result r1, Rule.Result r2, Rule.Result r3)
        {
            var input = new List <Hands.Unicode>()
            {
                p1, p2, p3
            };
            var actual   = Rule.Instance.Judge(input);
            var expected = new List <Rule.Result>()
            {
                r1, r2, r3
            };

            Assert.That(expected, Is.EqualTo(actual));
        }
        public void Judge_vsNPC_ReturnResult(Hands.Unicode player, Hands.Unicode npc, Rule.Result expected)
        {
            var actual = Rule.Instance.Judge(player, npc);

            Assert.AreEqual(expected, actual);
        }
        public void Result_Match_ReturnMessage(Rule.Result input, string expected)
        {
            var actual = Janken.Message.Instance.Result(input);

            Assert.AreEqual(expected, actual);
        }