コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: thxu/Th.Validator
        public void MaxTest()
        {
            string errMsg = string.Empty;
            int    res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 1f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 100.01f,
                    FloatField1 = 1f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));

            /*********************************************************************************/

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 100.01f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res == 100);
            Assert.IsTrue(string.IsNullOrEmpty(errMsg));

            errMsg = string.Empty;
            res    = 0;

            try
            {
                MaxModel model = new MaxModel
                {
                    FloatField  = 10.01f,
                    FloatField1 = 1000.01f,
                };
                res = new TestLogic().MaxTest(model);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            Assert.IsTrue(res != 100);
            Assert.IsTrue(!string.IsNullOrEmpty(errMsg));
        }
コード例 #2
0
ファイル: TestLogic.cs プロジェクト: thxu/Th.Validator
 public int MaxTest(MaxModel model)
 {
     return(100);
 }