Beispiel #1
0
        public void DecimalValueTests()
        {
            // arrange
            var actionHelper = CreateActionHelper();

            var itemMock = new SimpleFieldsClassMock();

            itemMock.SetCanReadProperty("DecimalField1", true);
            itemMock.SetCanReadProperty("DecimalField2", true);
            itemMock.SetCanReadProperty("DecimalField3", true);

            itemMock.DecimalField1 = itemMock.DecimalField2 = itemMock.DecimalField3 = 100;

            // act
            var actual1 = actionHelper.ReplaceFieldsWithValues("value = {DecimalField1}", itemMock, true);

            // assert
            Assert.AreEqual(string.Format("value = ${0}", itemMock.DecimalField1), actual1);

            // act
            var actual2 = actionHelper.ReplaceFieldsWithValues("value = {DecimalField2}", itemMock, true);

            // assert
            Assert.AreEqual(string.Format("value = {0}%", itemMock.DecimalField1), actual2);

            // act
            var actual3 = actionHelper.ReplaceFieldsWithValues("value = {DecimalField3}", itemMock, true);

            // assert
            Assert.AreEqual(string.Format("value = {0}", itemMock.DecimalField1), actual3);
        }
Beispiel #2
0
        public void DateTimeValueTests()
        {
            // arrange
            var actionHelper = CreateActionHelper();

            var itemMock = new SimpleFieldsClassMock();

            itemMock.SetCanReadProperty("DateField1", true);
            itemMock.SetCanReadProperty("DateField2", true);
            itemMock.SetCanReadProperty("DateField3", true);

            itemMock.DateField1 = itemMock.DateField2 = itemMock.DateField3 = DateTime.Today;

            // act
            var actual1 = actionHelper.ReplaceFieldsWithValues("DateTime = {DateField1}", itemMock, true);

            // assert
            Assert.AreEqual(string.Format("DateTime = {0}", DateTime.Today.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)), actual1);

            // act
            var actual2 = actionHelper.ReplaceFieldsWithValues("DateTime = {DateField2}", itemMock, true);

            // assert
            Assert.AreEqual(string.Format("DateTime = {0}", DateTime.Today.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern)), actual2);

            // act
            var actual3 = actionHelper.ReplaceFieldsWithValues("DateTime = {DateField3}", itemMock, true);

            // assert
            Assert.AreEqual(
                string.Format(
                    "DateTime = {0} {1}",
                    DateTime.Today.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern),
                    DateTime.Today.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern)),
                actual3);
        }