예제 #1
0
        //[TestMethod]
        //public void CompareTest_1_Same_4_Same_should_be_n1()
        //{
        //    var diceA = new DiceDto(1, DiceDto.StatusEnum.SameColor);
        //    var diceB = new DiceDto(4, DiceDto.StatusEnum.SameColor);
        //    var expected = 1;
        //    CompareAreEqual(diceA, diceB, expected);
        //}

        //[TestMethod]
        //public void CompareTest_4_Same_2_Same_should_be_n1()
        //{
        //    var diceA = new DiceDto(4, DiceDto.StatusEnum.SameColor);
        //    var diceB = new DiceDto(2, DiceDto.StatusEnum.SameColor);
        //    var expected = 1;
        //    CompareAreEqual(diceA, diceB, expected);
        //}

        //[TestMethod]
        //public void CompareTest_1_Same_2_Same_should_be_n1()
        //{
        //    var diceA = new DiceDto(1, DiceDto.StatusEnum.SameColor);
        //    var diceB = new DiceDto(2, DiceDto.StatusEnum.SameColor);
        //    var expected = 1;
        //    CompareAreEqual(diceA, diceB, expected);
        //}

//[TestMethod]
//        public void CompareTest_4_Same_5_Same_should_be_n1()
//        {
//            var diceA = new DiceDto(4, DiceDto.StatusEnum.SameColor);
//            var diceB = new DiceDto(5, DiceDto.StatusEnum.SameColor);
//            var expected = 1;
//            CompareAreEqual(diceA, diceB, expected);
//        }

        private static void CompareAreEqual(DiceDto diceA, DiceDto diceB, int expected)
        {
            var target = new Dice();
            var actual = target.Compare(diceA, diceB);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void CompareTest_1_Same_1_Same_should_be_0()
        {
            var diceA    = new DiceDto(1, DiceDto.StatusEnum.SameColor);
            var diceB    = new DiceDto(1, DiceDto.StatusEnum.SameColor);
            var expected = 0;

            CompareAreEqual(diceA, diceB, expected);
        }
예제 #3
0
        public void CompareTest_2_Same_3_Same_should_be_n1()
        {
            var diceA    = new DiceDto(2, DiceDto.StatusEnum.SameColor);
            var diceB    = new DiceDto(3, DiceDto.StatusEnum.SameColor);
            var expected = -1;

            CompareAreEqual(diceA, diceB, expected);
        }
예제 #4
0
        public void CompareTest_1_Point_1_NoPoint_should_be_1()
        {
            var diceA    = new DiceDto(1, DiceDto.StatusEnum.Points);
            var diceB    = new DiceDto(1, DiceDto.StatusEnum.NoPoints);
            var expected = 1;

            CompareAreEqual(diceA, diceB, expected);
        }
예제 #5
0
        public int Compare(DiceDto diceA, DiceDto diceB)
        {
            var statusA = (int)diceA.Status;
            var statusB = (int)diceB.Status;

            if (statusA < statusB)
            {
                return(1);
            }

            if (statusA > statusB)
            {
                return(-1);
            }

            if (diceA.Status == diceB.Status)
            {
                //if (diceA.Status == DiceDto.StatusEnum.SameColor)
                //{
                //    var samecolororder = new List<int> { 1, 4, 6, 5, 3, 2 };
                //    var dnumber = diceA.DicePoints)/4;
                //    if (samecolororder.IndexOf(dnumber);

                //}

                if (diceA.DicePoints == diceB.DicePoints)
                {
                    return(0);
                }
                if (diceA.DicePoints > diceB.DicePoints)
                {
                    return(1);
                }
                if (diceA.DicePoints < diceB.DicePoints)
                {
                    return(-1);
                }
            }
            return(0);


            throw new NotImplementedException();
        }