Example #1
0
            public void ConvertIntArrayToStringEnumerable()
            {
                // Given
                MetadataDictionary initialMetadata = new MetadataDictionary();
                MetadataStack      metadata        = new MetadataStack(initialMetadata);

                // When
                metadata = metadata.Clone(new[] { new KeyValuePair <string, object>("A", new int[] { 1, 2, 3 }) });
                IMetadata <IEnumerable <string> > metadataAs = metadata.MetadataAs <IEnumerable <string> >();

                // Then
                CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadata["A"]);
                CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, metadataAs["A"]);
            }
Example #2
0
            public void ConvertStringToIntArray()
            {
                // Given
                MetadataDictionary initialMetadata = new MetadataDictionary();
                MetadataStack      metadata        = new MetadataStack(initialMetadata);

                // When
                metadata = metadata.Clone(new[] { new KeyValuePair <string, object>("A", "1") });
                IMetadata <int[]> metadataAs = metadata.MetadataAs <int[]>();

                // Then
                Assert.AreEqual("1", metadata["A"]);
                CollectionAssert.AreEqual(new int[] { 1 }, (IEnumerable)metadataAs["A"]);
            }
Example #3
0
            public void ConvertIntToString()
            {
                // Given
                MetadataDictionary initialMetadata = new MetadataDictionary();
                MetadataStack      metadata        = new MetadataStack(initialMetadata);

                // When
                metadata = metadata.Clone(new[] { new KeyValuePair <string, object>("A", 1) });
                IMetadata <string> metadataAs = metadata.MetadataAs <string>();

                // Then
                Assert.AreEqual(1, metadata["A"]);
                Assert.AreEqual("1", metadataAs["A"]);
            }
Example #4
0
 public IMetadata <T> MetadataAs <T>() => _metadata.MetadataAs <T>();