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"]); }
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"]); }
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"]); }
public IMetadata <T> MetadataAs <T>() => _metadata.MetadataAs <T>();