Exemplo n.º 1
0
        public void It_can_convert_multi_values_to_Binary()
        {
            var base64Jpeg1 = @"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwkHBgoJCAkLCwoMDxkQDw4ODx4WFxIZJCAmJSMgIyIoLTkwKCo2KyIjMkQyNjs9QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT3/wAARCAAyADIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD2CS6t42KvPGrDqCwBpv221/5+Yf8AvsV494+O3xpfgZGPL7/9M1rnsn1P51i6tnY+pw/DqrUYVPaW5knt3XqfQDXdqf8Al4h/77FcBoHjKPS9dvNOvmAs3uZDFLj/AFZLHr6g+vb6V59uPrRuO7Oec5zUuo2d+H4fp04ThOXMpeVreZ9DowYZBBUjIIPWnV5Z4L8anT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6V59uPrRuO7Oec5zUuo2d+H4fp04ThOXMpeVreZ9DowYZBBUjIIPWnV5Z4L8anTymn6m5a0J2xSt/yy9if7v8vpXqKuGAKkFSMgg9a2jJSR8rjsBUwdTknt0fcfRSUVRwni/j/wD5HXUP+2f/AKLWudrovH//ACOuof8AbP8A9FrXO1yS3Z+nYD/dKX+GP5IKKKKk6xQcGu18GeNTpzJp2pvm0biOVusR9D/s/wAq4quu8F+Dn1iVb29QixjbhT/y2I7fT1NXC99Dzs0jhnh5fWNvxv5ef9bHqI1K1IBE8WP94UUz+ybD/nzg/wC/YorqPz21Lz/A8k8e8eMr/wD7Z/8Aota57Nez6n4L0nVtQlu7qKRppMbiJCBwABx9BVX/AIVxoX/PvL/3+NYSpSbbPrcLn+FpUIU5J3SS27L1PIutBGK9e/4VzoOP9RLn/rsa4rRfB0ms+ILqLDR6fbTMjv3wGPyj3x+VQ6ckd9DOsLWjKaulHe4zwd4RfX7nz7oMlhEfmYcGQ/3R/U16/DBHBCkUKCONAAqqMACmWlpDZ26W9tGI4Y1Cqi9ABU/WuiEeVHx2Y5jPHVOZ6RWy/rqFFLRVHnBRRRQA09DWP4aH/EumPf7TN/6GaKKSOin/AAJ+q/U2aWiimc4UUUUAf//Z";

            var it = new IdmAttribute { Name = "foo", Values = new List<string> { base64Jpeg1, base64Jpeg2, base64Jpeg3 } };
            List<byte[]> result = it.ToBinaries();

            Assert.IsNotNull(result);
            Assert.AreEqual(255, result[0][0]);
            Assert.AreEqual(216, result[0][1]);
            Assert.AreEqual(255, result[0][2]);
            Assert.AreEqual(217, result[0][result[0].Length - 1]);

            Assert.AreEqual(255, result[1][0]);
            Assert.AreEqual(216, result[1][1]);
            Assert.AreEqual(255, result[1][2]);
            Assert.AreEqual(217, result[1][result[1].Length - 1]);

            Assert.AreEqual(255, result[1][0]);
            Assert.AreEqual(216, result[1][1]);
            Assert.AreEqual(255, result[1][2]);
            Assert.AreEqual(217, result[1][result[1].Length - 1]);
        }
Exemplo n.º 2
0
        public void It_can_convert_multi_values_to_Integers()
        {
            var stringRepresentation0 = @"123";
            var stringRepresentation1 = @"456";
            var stringRepresentation2 = @"789";

            var it = new IdmAttribute { Name = "foo", Values = new List<string> { stringRepresentation0, stringRepresentation1, stringRepresentation2 } };
            List<int> result = it.ToIntegers();

            Assert.IsNotNull(result);
            Assert.AreEqual(123, result[0]);
            Assert.AreEqual(456, result[1]);
            Assert.AreEqual(789, result[2]);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set all attribute values on an named attribute object
        /// </summary>
        /// <param name="attrName">Name of the attribute to retrieve</param>
        /// <param name="values">list of attrbute values</param>
        public void SetAttrValues(string attrName, List <string> values)
        {
            IdmAttribute attr = GetAttr(attrName);

            if (attr != null)
            {
                attr.Values = values;
            }
            Attributes.Add(new IdmAttribute()
            {
                Name   = attrName,
                Values = values
            });
        }
Exemplo n.º 4
0
        public void It_can_convert_multi_values_to_DateTime()
        {
            var now = DateTime.Now;
            var testTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
            var timeString1 = testTime.ToString(CultureInfo.InvariantCulture);
            var timeString2 = testTime.AddDays(1).ToString(CultureInfo.InvariantCulture);
            var timeString3 = testTime.AddDays(2).ToString(CultureInfo.InvariantCulture);

            var it = new IdmAttribute { Name = "foo", Values = new List<string> { timeString1, timeString2, timeString3 } };
            var result = it.ToDateTimes();

            Assert.AreEqual(testTime, result[0]);
            Assert.AreEqual(testTime.AddDays(1), result[1]);
            Assert.AreEqual(testTime.AddDays(2), result[2]);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set just a single value on a named attribute object
        /// </summary>
        /// <param name="attrName">Name of the attribute to set</param>
        /// <param name="value">Value to set for the attribute</param>
        public void SetAttrValue(string attrName, string value)
        {
            IdmAttribute attr = GetAttr(attrName);

            if (attr != null)
            {
                attr.Value = value;
            }
            else
            {
                Attributes.Add(new IdmAttribute()
                {
                    Name  = attrName,
                    Value = value
                });
            }
        }
Exemplo n.º 6
0
        public void ConvertMultiValuedIntegerAttributeToListOfInts()
        {
            // Arrange
            var multiAttr = new IdmAttribute
            {
                Name = "MyInts",
                Values = new List<string>
                {
                    "1",
                    "2",
                    "3"
                }
            };

            // Act
            List<int> converted = multiAttr.Values.Select(int.Parse).ToList();

            // Assert
            Assert.AreEqual(1, converted[0]);
            Assert.AreEqual(2, converted[1]);
            Assert.AreEqual(3, converted[2]);
        }
Exemplo n.º 7
0
        public void It_can_convert_the_value_to_bool()
        {
            var it = new IdmAttribute { Name = "foo", Values = new List<string> { "true" } };
            var result = it.ToBool();

            Assert.IsTrue(result != null && result.Value);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get all attribute values from an attribute object by name
        /// </summary>
        /// <param name="attrName">Name of the attribute to retrieve</param>
        /// <returns>list of attrbute values</returns>
        public List <string> GetAttrValues(string attrName)
        {
            IdmAttribute attr = GetAttr(attrName);

            return(attr?.Values);
        }
Exemplo n.º 9
0
        public void It_can_convert_the_value_to_Integer()
        {
            var stringRepresentation = @"123";

            var it = new IdmAttribute { Name = "foo", Values = new List<string> { stringRepresentation } };
            int? result = it.ToInteger();

            Assert.IsNotNull(result);
            Assert.AreEqual(123, result);
        }
Exemplo n.º 10
0
        public void It_can_convert_the_value_to_DateTime()
        {
            var now = DateTime.Now;
            var testTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
            var timeString = testTime.ToString(CultureInfo.InvariantCulture);

            var it = new IdmAttribute { Name = "foo", Values = new List<string> { timeString } };
            var result = it.ToDateTime();

            Assert.IsNotNull(result);
            Assert.AreEqual(testTime, result);
        }
Exemplo n.º 11
0
        public void It_should_set_the_value_if_it_is_empty_to_start()
        {
            var it = new IdmAttribute();

            it.Value = "foo";

            Assert.AreEqual("foo", it.Value);
        }
Exemplo n.º 12
0
        public void It_should_set_the_value_if_it_is_not_empty_to_start()
        {
            var it = new IdmAttribute { Values = new List<string> { "bar" } };

            it.Value = "foo";

            Assert.AreEqual("foo", it.Value);
        }
Exemplo n.º 13
0
        public void It_should_return_null_if_no_value_set()
        {
            var it = new IdmAttribute();

            Assert.IsNull(it.Value);
        }
Exemplo n.º 14
0
        public void It_should_return_the_first_value_if_multiple_values_set()
        {
            var it = new IdmAttribute { Values = new List<string> { "foo", "bar", "bat" } };

            Assert.AreEqual("foo", it.Value);
        }
Exemplo n.º 15
0
        public void It_should_return_just_the_value_if_value_set()
        {
            var it = new IdmAttribute { Values = new List<string> { "foo" } };

            Assert.AreEqual("foo", it.Value);
        }
Exemplo n.º 16
0
        public void It_can_convert_to_a_DateTime_when_appropriate_value_is_present()
        {
            var it = new IdmAttribute { Values = new List<string> { "bar", "bat" } };

            it.Value = "foo";

            Assert.AreEqual(1, it.Values.Count);
        }
Exemplo n.º 17
0
        public void It_should_replace_all_values_on_setting_Value()
        {
            var it = new IdmAttribute { Values = new List<string> { "bar", "bat" } };

            it.Value = "foo";

            Assert.AreEqual(1, it.Values.Count);
        }
Exemplo n.º 18
0
        public void It_returns_null_when_no_values_are_not_present()
        {
            var it = new IdmAttribute { Name = "foo" };
            var result = it.ToIntegers();

            Assert.IsNull(result);
        }
Exemplo n.º 19
0
        public void It_returns_null_when_no_DateTime_Exists()
        {
            var it = new IdmAttribute { Name = "foo" };
            var result = it.ToDateTimes();

            Assert.IsNull(result);
        }