Ejemplo n.º 1
0
        public void InstanceSerialiseDeserialise()
        {
            var originalInstance = new Instance()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                Name = "Test Instance",
                Tags = new Dictionary<string, string>()
                {
                    { "tagKey", "Some tag value." },
                    { "secondKey", "Multiline \r\n   test!" }
                }
            };

            Instance secondInstance;
            using (var stream = originalInstance.Serialise())
            {
                secondInstance = new Instance(stream);
            }

            Assert.AreEqual(originalInstance.Key, secondInstance.Key);
            Assert.AreEqual(originalInstance.GroupKey, secondInstance.GroupKey);
            Assert.AreEqual(originalInstance.TargetKey, secondInstance.TargetKey);
            Assert.AreEqual(originalInstance.Name, secondInstance.Name);

            Assert.IsNotNull(secondInstance.Tags);
            foreach (var tag in originalInstance.Tags)
            {
                Assert.IsTrue(secondInstance.Tags.ContainsKey(tag.Key));
                Assert.AreEqual(tag.Value, secondInstance.Tags[tag.Key]);
            }
        }
Ejemplo n.º 2
0
        public void InstanceSerialiseDeserialiseNullTags()
        {
            var originalInstance = new Instance()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                Name = "Test Instance",
            };

            Instance secondInstance;
            using (var stream = originalInstance.Serialise())
            {
                secondInstance = new Instance(stream);
            }

            Assert.AreEqual(originalInstance.Key, secondInstance.Key);
            Assert.AreEqual(originalInstance.GroupKey, secondInstance.GroupKey);
            Assert.AreEqual(originalInstance.TargetKey, secondInstance.TargetKey);
            Assert.AreEqual(originalInstance.Name, secondInstance.Name);

            Assert.AreEqual(originalInstance.Tags.Count, secondInstance.Tags.Count);
        }