public void ClonedMetadataDoesNotContainNewValues() { // Given InitialMetadata initialMetadata = new InitialMetadata {["A"] = "a"}; Metadata metadata = new Metadata(initialMetadata); // When Metadata clone = metadata.Clone(new Dictionary<string, object> {{"B", "b"}}); // Then Assert.IsFalse(metadata.ContainsKey("B")); }
public void ContainsPreviousValues() { // Given InitialMetadata initialMetadata = new InitialMetadata {["A"] = "a"}; Metadata metadata = new Metadata(initialMetadata); // When Metadata clone = metadata.Clone(new Dictionary<string, object> {{"B", "b"}}); // Then Assert.AreEqual("a", clone["A"]); }
public void CanCloneWithNewValues() { // Given InitialMetadata initialMetadata = new InitialMetadata(); Metadata metadata = new Metadata(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "a") }); // Then Assert.AreEqual("a", metadata["A"]); }
public void CanCloneWithNewValues() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); Metadata metadata = new Metadata(engine); // When metadata = metadata.Clone(new [] { new KeyValuePair<string, object>("A", "a") }); // Then Assert.AreEqual("a", metadata["A"]); }
public void ConvertStringArrayToIntArray() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); Metadata metadata = new Metadata(engine); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new string[] { "1", "2", "3" }) }); IMetadata<int[]> metadataAs = metadata.MetadataAs<int[]>(); // Then CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, (IEnumerable)metadata["A"]); CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadataAs["A"]); }
public void ConvertStringToInt() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); Metadata metadata = new Metadata(engine); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "1") }); IMetadata<int> metadataAs = metadata.MetadataAs<int>(); // Then Assert.AreEqual("1", metadata["A"]); Assert.AreEqual(1, metadataAs["A"]); }
public void ReplacesValue() { // Given InitialMetadata initialMetadata = new InitialMetadata {["A"] = "a"}; Metadata metadata = new Metadata(initialMetadata); // When Metadata clone = metadata.Clone(new Dictionary<string, object> {{"A", "b"}}); // Then Assert.AreEqual("a", metadata["A"]); Assert.AreEqual("b", clone["A"]); }
public void ConvertStringToIntArray() { // Given InitialMetadata initialMetadata = new InitialMetadata(); Metadata metadata = new Metadata(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 ConvertStringToInt() { // Given InitialMetadata initialMetadata = new InitialMetadata(); Metadata metadata = new Metadata(initialMetadata); // When metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "1") }); IMetadata<int> metadataAs = metadata.MetadataAs<int>(); // Then Assert.AreEqual("1", metadata["A"]); Assert.AreEqual(1, metadataAs["A"]); }
public void ConvertIntArrayToStringEnumerable() { // Given InitialMetadata initialMetadata = new InitialMetadata(); Metadata metadata = new Metadata(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 CloneReplacesValue() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); engine.Metadata["A"] = "a"; Metadata metadata = new Metadata(engine); // When Metadata clone = metadata.Clone(new Dictionary<string, object> { { "A", "b" } }); // Then Assert.AreEqual("a", metadata["A"]); Assert.AreEqual("b", clone["A"]); }
public void ClonedMetadataDoesNotContainNewValues() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); engine.Metadata["A"] = "a"; Metadata metadata = new Metadata(engine); // When Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } }); // Then Assert.IsFalse(metadata.ContainsKey("B")); }