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 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 ReturnsCorrectFilePathForFilePath(string path, string expected) { // Given MetadataDictionary initialMetadata = new MetadataDictionary(); MetadataStack metadata = new MetadataStack(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new FilePath(path)) }); object result = metadata.FilePath("A"); // Then Assert.IsInstanceOf<FilePath>(result); Assert.AreEqual(expected, ((FilePath)result).FullPath); }
public void ReturnsCorrectDirectoryPathForString(string path, string expected) { // Given MetadataDictionary initialMetadata = new MetadataDictionary(); MetadataStack metadata = new MetadataStack(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", path) }); object result = metadata.DirectoryPath("A"); // Then if (expected == null) { Assert.IsNull(result); } else { Assert.IsInstanceOf<DirectoryPath>(result); Assert.AreEqual(expected, ((DirectoryPath)result).FullPath); } }
public void ReturnsCorrectStringForDirectoryPath(string path, string expected) { // Given MetadataDictionary initialMetadata = new MetadataDictionary(); MetadataStack metadata = new MetadataStack(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new DirectoryPath(path)) }); object result = metadata.String("A"); // Then Assert.IsInstanceOf<string>(result); Assert.AreEqual(expected, result); }
public void ReplacesValue() { // Given MetadataDictionary initialMetadata = new MetadataDictionary {["A"] = "a"}; MetadataStack metadata = new MetadataStack(initialMetadata); // When MetadataStack clone = metadata.Clone(new Dictionary<string, object> {{"A", "b"}}); // Then Assert.AreEqual("a", metadata["A"]); Assert.AreEqual("b", clone["A"]); }
public void ContainsNewValues() { // Given MetadataDictionary initialMetadata = new MetadataDictionary {["A"] = "a"}; MetadataStack metadata = new MetadataStack(initialMetadata); // When MetadataStack clone = metadata.Clone(new Dictionary<string, object> {{"B", "b"}}); // Then Assert.AreEqual("b", clone["B"]); }
public void ClonedMetadataDoesNotContainNewValues() { // Given MetadataDictionary initialMetadata = new MetadataDictionary {["A"] = "a"}; MetadataStack metadata = new MetadataStack(initialMetadata); // When MetadataStack clone = metadata.Clone(new Dictionary<string, object> {{"B", "b"}}); // Then Assert.IsFalse(metadata.ContainsKey("B")); }
public void CanCloneWithNewValues() { // Given MetadataDictionary initialMetadata = new MetadataDictionary(); MetadataStack metadata = new MetadataStack(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "a") }); // Then Assert.AreEqual("a", metadata["A"]); }