Beispiel #1
0
        public void WithoutArguments()
        {
            RowAttribute row = new RowAttribute();

            Assert.That(row.Arguments, Is.Not.Null);
            Assert.That(row.Arguments, Is.Empty);
        }
Beispiel #2
0
        public void ArgumentsAreProvided()
        {
            object[] arguments = new object[] { 4, 5, 6 };

            RowAttribute row = new RowAttribute(arguments);

            Assert.That(row.Arguments, Is.SameAs(arguments));
        }
Beispiel #3
0
        public void RowAttributeNumberConversion()
        {
            RowAttribute ra = new RowAttribute("25.5", "2006.32323", "90.2323289329329832");

            object[] row = ra.GetRow(GetParametersForMethod("RowAttributeNumberConversionParameters"));
            Assert.AreEqual(row[0], 25.5f);
            Assert.AreEqual(row[1], 2006.32323d);
            Assert.AreEqual(row[2], 90.2323289329329832m);
        }
        public void GetRowArguments()
        {
            object[]     rowArguments = new object[] { 4, 5 };
            RowAttribute row          = new RowAttribute(rowArguments);

            object[] extractedRowArguments = RowTestFramework.GetRowArguments(row);

            Assert.That(extractedRowArguments, Is.SameAs(rowArguments));
        }
Beispiel #5
0
		public void GetRowArguments()
		{
			object[] rowArguments = new object[] { 4, 5 };
			RowAttribute row = new RowAttribute(rowArguments);
			
			object[] extractedRowArguments = RowTestFramework.GetRowArguments(row);
			
			Assert.That(extractedRowArguments, Is.SameAs(rowArguments));
		}
Beispiel #6
0
        private void SetRowHeaderHeight(int rowIndex, Type type)
        {
            var attr = type.GetCustomAttributes(typeof(RowAttribute), true);

            if (attr.Any())
            {
                RowAttribute rowAttr = attr.First() as RowAttribute;
                SetRowHeight(rowIndex, rowAttr.HeaderHeight);
            }
        }
Beispiel #7
0
        public void RowAttributeDateTimeConversion(string dateString, int year, int month, int day,
                                                   int hour, int minute, int second)
        {
            RowAttribute ra = new RowAttribute(dateString);

            object[] row = ra.GetRow(GetParametersForMethod("RowAttributeDateTimeConversionParameters"));
            DateTime dt  = (DateTime)row[0];

            AssertDateTimeValues(dt, year, month, day, hour, minute, second);
        }
Beispiel #8
0
        public void NullWasPassedAsArguments()
        {
            object[] arguments = null;

            RowAttribute row = new RowAttribute(arguments);

            Assert.That(row.Arguments, Is.Not.Null);
            Assert.That(row.Arguments.Length, Is.EqualTo(1));
            Assert.That(row.Arguments[0], Is.Null);
        }
        public void GetExpectedExceptionType()
        {
            Type         expectedExceptionType = typeof(ArgumentException);
            RowAttribute row = CreateRowAttribute();

            row.ExpectedException = expectedExceptionType;

            Type extractedExpectedExceptionType = RowTestFramework.GetExpectedExceptionType(row);

            Assert.That(extractedExpectedExceptionType, Is.SameAs(expectedExceptionType));
        }
        public void GetTestName()
        {
            string       testName = "UnitTest";
            RowAttribute row      = CreateRowAttribute();

            row.TestName = testName;

            string extractedTestName = RowTestFramework.GetTestName(row);

            Assert.That(extractedTestName, Is.EqualTo(testName));
        }
Beispiel #11
0
        private int GetRowHeightStyle(Type type)
        {
            var attr = type.GetCustomAttributes(typeof(RowAttribute), true);

            if (!attr.Any())
            {
                return(0);
            }
            RowAttribute rowAttr = attr.First() as RowAttribute;

            return(rowAttr.Height);
        }
        public void GetExpectedExceptionMessage()
        {
            string       expectedExceptionMessage = "Expected Exception Message.";
            Type         expectedExceptionType    = typeof(ArgumentException);
            RowAttribute row = CreateRowAttribute();

            row.ExceptionMessage = expectedExceptionMessage;

            string extractedExceptionMessage = RowTestFramework.GetExpectedExceptionMessage(row);

            Assert.That(extractedExceptionMessage, Is.SameAs(expectedExceptionMessage));
        }
Beispiel #13
0
        /// <summary>
        /// 根据类型的Row特性指示是否执行严格的显示控制
        /// </summary>
        /// <param name="type">类型</param>
        /// <returns></returns>
        private bool IsStrict(Type type)
        {
            var attr = type.GetCustomAttributes(typeof(RowAttribute), true);

            if (attr.Any())
            {
                RowAttribute rowAttr = attr.First() as RowAttribute;
                return(rowAttr.IsStrict);
            }
            else
            {
                return(false);
            }
        }
Beispiel #14
0
        private Style CreateEvenRowStyle(Type type)
        {
            var attr = type.GetCustomAttributes(typeof(RowAttribute), true);

            if (!attr.Any())
            {
                return(null);
            }
            RowAttribute rowAttr = attr.First() as RowAttribute;

            if (rowAttr.EvenRowColor == ExcelColor.None)
            {
                return(null);
            }
            var style = _workbook.NewStyle(type.FullName + ".Even");

            style.BackColor = rowAttr.EvenRowColor;
            return(style);
        }
Beispiel #15
0
        public static Dictionary <string, string> GetFieldTextList <T>(this string line) where T : class
        {
            Dictionary <string, string> result = new Dictionary <string, string>();
            RowAttribute attribute             = Attribute.GetCustomAttribute((typeof(T)), typeof(RowAttribute))
                                                 as RowAttribute;

            if (attribute != null)
            {
                char     interSplitter = attribute.InterColumnSplitter;
                char     intraSplitter = attribute.IntraColumnSplitter;
                string[] fields        = line.GetSplittedFields(interSplitter);
                foreach (string field in fields)
                {
                    string[] intraFields = field.GetSplittedFields(intraSplitter);
                    result.Add(intraFields[0], intraFields[1]);
                }
            }
            return(result);
        }
Beispiel #16
0
        private Style CreateRowHeaderStyle(Type type)
        {
            var attr = type.GetCustomAttributes(typeof(RowAttribute), true);

            if (!attr.Any())
            {
                return(null);
            }
            RowAttribute rowAttr = attr.First() as RowAttribute;
            Font         font    = new Font(type.FullName + ".Header");

            font.Family = rowAttr.HeaderFontFamily;
            font.Size   = rowAttr.HeaderFontSize;
            font.Color  = rowAttr.HeaderFontColor;
            Style style = _workbook.NewStyle(type.FullName + ".Header");

            style.Font      = font;
            style.BackColor = rowAttr.HeaderBackColor;
            style.Height    = rowAttr.HeaderHeight;
            style.HorAlign  = rowAttr.HeaderHorAlign;
            style.VerAlign  = rowAttr.HeaderVerAlign;
            style.Width     = 0;
            return(style);
        }
Beispiel #17
0
 public RowField(FieldInfo field, RowAttribute attribute)
 {
     Field     = field;
     Attribute = attribute;
 }
Beispiel #18
0
 public RowMethodRunInvoker(IRun generator, MethodInfo method, RowAttribute row)
     : base(generator)
 {
     this.method = method;
     this.row    = row;
 }
 public ComplexRowField(FieldInfo field, RowAttribute attribute) : base(field, attribute)
 {
 }
Beispiel #20
0
 public ListRowField(FieldInfo field, RowAttribute attribute)
     : base(field, attribute)
 {
 }