예제 #1
0
        public void TestWithDatetimeNow()
        {
            //Find now
            string dateTimeNow = DateTime.Now.ToString();

            Assert.IsTrue(ParseStringToType.StringToDateTime(dateTimeNow).ToString() == dateTimeNow);
        }
예제 #2
0
        public void TestWhenFormatIsRight()
        {
            //The date to parse
            string dateTime = "25/07/2017 12:47:00";

            Assert.IsTrue(ParseStringToType.StringToDateTime(dateTime).ToString() == dateTime);
        }
        public void TestStringNotFound()
        {
            ProductType productType;

            productType = ParseStringToType.ProductType("Foods");

            Assert.AreEqual(productType, ProductType.NotFound);
        }
        public void TestStringToHousehold()
        {
            ProductType productType;

            productType = ParseStringToType.ProductType("Household");

            Assert.AreEqual(productType, ProductType.Household);
        }
        public void TestStringToFun()
        {
            ProductType productType;

            productType = ParseStringToType.ProductType("Fun");

            Assert.AreEqual(productType, ProductType.Fun);
        }
        public void TestStringToSnack()
        {
            ProductType productType;

            productType = ParseStringToType.ProductType("Snack");

            Assert.AreEqual(productType, ProductType.Snack);
        }
        public void TestStringToFood()
        {
            ProductType productType;

            productType = ParseStringToType.ProductType("Food");

            Assert.AreEqual(productType, ProductType.Food);
        }
예제 #8
0
        public void TestWhenComponentIsNegative()
        {
            //Be sure the right exception is cast
            bool   exceptionIsCast = false;
            string dateTime        = "-5/07/2017 12:47:00";

            try
            {
                Console.WriteLine(ParseStringToType.StringToDateTime(dateTime));
                Console.ReadKey();
            }
            catch (FormatException)
            {
                exceptionIsCast = true;
            }
            catch (Exception)
            {
            }
            Assert.AreEqual(exceptionIsCast, true);
        }
예제 #9
0
        public void TestWhenYearformatIsWrong()
        {
            //Becomes true if the right exception is cast
            bool   formatExceptionIsCast = false;
            string wrongYearFormat       = "25/07/17 12:30:05";

            try
            {
                Console.WriteLine(ParseStringToType.StringToDateTime(wrongYearFormat));
                Console.ReadKey();
            }
            catch (FormatException)
            {
                formatExceptionIsCast = true;
            }
            catch (Exception)
            {
            }
            Assert.AreEqual(formatExceptionIsCast, true);
        }
예제 #10
0
        public void TestWhenWrongSeparators()
        {
            //Be sure the right exception is cast
            bool   exceptionIsCast = false;
            string dateTime        = "22:22/2222 22:22:22";

            try
            {
                Console.WriteLine(ParseStringToType.StringToDateTime(dateTime));
                Console.ReadKey();
            }
            catch (FormatException)
            {
                exceptionIsCast = true;
            }
            catch (Exception)
            {
            }
            Assert.AreEqual(exceptionIsCast, true);
        }
예제 #11
0
        public void TestNotFound()
        {
            UnitType type = ParseStringToType.UnitType("Ll");

            Assert.AreEqual(type, UnitType.notFound);
        }
예제 #12
0
        public void TestRightWhenPiece()
        {
            UnitType type = ParseStringToType.UnitType("piece");

            Assert.AreEqual(type, UnitType.piece);
        }
예제 #13
0
        public void TestRightWheng()
        {
            UnitType type = ParseStringToType.UnitType("g");

            Assert.AreEqual(type, UnitType.g);
        }