Example #1
0
        public void BugBinarySizeDiffer()
        {
            INamedVersionedUniqueId uid1 = SharedDicTestContext.Plugins[0];
            INamedVersionedUniqueId uid2 = SharedDicTestContext.Plugins[1];
            string path = TestBase.GetTestFilePath("SharedDic", "BugBinarySizeDiffer");

            SharedDictionaryTester checker = new SharedDictionaryTester("BugBinarySizeDiffer", path, this, uid1, uid2, (d, o, id) => d[o, id, "Obj"] = new SerializableObject());

            checker.WriteAndReadWithTests(
                d => d.SelectSingleNode(@"CK-Structured/BugBinarySizeDiffer/p/data[@key=""Obj""]").Attributes["size"].Value = "1",
                dic => { dic.Ensure(uid1);  dic.Ensure(uid2); });

            Assert.That(checker.Errors.Count, Is.EqualTo(1));
            Assert.That(checker.Errors[0].HasError, Is.True);
        }
Example #2
0
        private ISharedDictionary BuggyReader <T>(int expectedErrorCount) where T : BuggyObjectBase, new()
        {
            INamedVersionedUniqueId uid1 = SharedDicTestContext.Plugins[0];
            INamedVersionedUniqueId uid2 = SharedDicTestContext.Plugins[1];

            string path = TestBase.GetTestFilePath("SharedDic", typeof(T).Name);

            SharedDictionaryTester checker = new SharedDictionaryTester(typeof(T).Name, path, this, uid1, uid2, (d, o, id) =>
            {
                Assert.That(id == uid1);
                d[o, id, "AnotherValue"] = 13;
                d[o, id, "Obj"]          = new T()
                {
                    Name = "No Bug for this one!"
                };
                d[o, id, "Obj2"] = new T()
                {
                    BugWhileReading = BugRead.SkipTag, Name = "This name will not be read back. (But the object exists.)"
                };
                d[o, id, "Obj3"] = new T()
                {
                    BugWhileReading = BugRead.MoveToEndTag, Name = "This name will not be read back. (But the object exists.)"
                };
                d[o, id, "Obj4"] = new T()
                {
                    BugWhileReading = BugRead.Throw, Name = "This object should not exist at all..."
                };
                d[o, id, "YetAnotherValue"] = 87;
            });
            ISharedDictionary d2 = checker.WriteAndReadWithTests(null, dic => { dic.Ensure(uid1); dic.Ensure(uid2); });

            TestBase.DumpFileToConsole(path);

            Assert.That(checker.Errors.Count, Is.EqualTo(expectedErrorCount));
            Assert.That(checker.Errors.All(e => e.HasError));

            Assert.That(d2[this, uid1, "AnotherValue"], Is.EqualTo(13));
            Assert.That(((BuggyObjectBase)d2[this, uid1, "Obj"]).Name, Is.EqualTo("No Bug for this one!"));
            Assert.That(((BuggyObjectBase)d2[this, uid1, "Obj2"]).Name, Is.EqualTo("Default Name"));
            Assert.That(((BuggyObjectBase)d2[this, uid1, "Obj3"]).Name, Is.EqualTo("Default Name"));
            Assert.That(d2[this, uid1, "Obj4"], Is.Null);

            return(d2);
        }
Example #3
0
        public void BugBinaryBadContent()
        {
            INamedVersionedUniqueId uid1 = SharedDicTestContext.Plugins[0];
            INamedVersionedUniqueId uid2 = SharedDicTestContext.Plugins[1];
            string path = TestBase.GetTestFilePath("SharedDic", "BugBinaryBadContent");

            SharedDictionaryTester checker = new SharedDictionaryTester("BugBinaryBadContent", path, this, uid1, uid2, (d, o, id) => d[o, id, "Obj"] = new SerializableObject());

            Assert.Throws <XmlException>(() =>
            {
                checker.WriteAndReadWithTests
                (
                    d =>
                {
                    XmlNode n   = d.SelectSingleNode(@"CK-Structured/BugBinaryBadContent/p/data[@key=""Obj""]");
                    n.InnerText = n.InnerText.Insert(n.InnerText.Length / 2, "*bug*");
                },
                    dic => { dic.Ensure(uid1); dic.Ensure(uid2); }
                );
            });
        }