Ejemplo n.º 1
0
        public void GetValue_NestedStringDateTimeTransformation_ReturnsString()
        {
            var transformed = new StringDateTimeDataItem(
                new DictionaryDataItem(new Dictionary <string, object>
            {
                { "StringProperty", "Nested world!" },
                { "Nested", new Dictionary <string, object>
                  {
                      { "DateTimeProperty", new DateTime(2010, 5, 3, 1, 0, 0, DateTimeKind.Utc) }
                  } }
            }));

            CollectionAssert.AreEquivalent(new[] { "StringProperty", "Nested" }, transformed.GetFieldNames().ToArray(),
                                           TestResources.InvalidFieldNames);

            Assert.AreEqual("Nested world!", transformed.GetValue("StringProperty"), TestResources.InvalidFieldValue);

            var nested = transformed.GetValue("Nested") as IDataItem;

            Assert.IsNotNull(nested, TestResources.NullNestedDataItem);

            CollectionAssert.AreEquivalent(new[] { "DateTimeProperty" }, nested.GetFieldNames().ToArray(),
                                           TestResources.InvalidFieldNames);

            Assert.AreEqual("2010-05-03T01:00:00.0000000Z", nested.GetValue("DateTimeProperty"), TestResources.InvalidFieldValue);
        }
Ejemplo n.º 2
0
        public void GetValue_TopLevelStringDateTimeTransformation_ReturnsString()
        {
            var transformed = new StringDateTimeDataItem(
                new DictionaryDataItem(new Dictionary <string, object>
            {
                { "StringProperty", "Hello world!" },
                { "DateTimeProperty", new DateTime(2015, 3, 1, 20, 10, 5, DateTimeKind.Utc) }
            }));

            CollectionAssert.AreEquivalent(new[] { "StringProperty", "DateTimeProperty" }, transformed.GetFieldNames().ToArray(),
                                           TestResources.InvalidFieldNames);

            Assert.AreEqual("Hello world!", transformed.GetValue("StringProperty"), TestResources.InvalidFieldValue);
            Assert.AreEqual("2015-03-01T20:10:05.0000000Z", transformed.GetValue("DateTimeProperty"), TestResources.InvalidFieldValue);
        }