コード例 #1
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void Merge()
        {
            var set1 = new PropertySet();

            set1.SetValue("key1", "value1");
            set1.SetValue("key2", "value2");

            var set2 = new PropertySet();

            set2.SetValue("key1", "value1bis");
            set2.SetValue("key3", "value3");

            set1.MergeWith(set2);

            Assert.AreElementsEqualIgnoringOrder(set1, new[]
            {
                new KeyValuePair <string, string>("key1", "value1"),
                new KeyValuePair <string, string>("key2", "value2"),
                new KeyValuePair <string, string>("key3", "value3"),
            });

            Assert.AreElementsEqualIgnoringOrder(set2, new[]
            {
                new KeyValuePair <string, string>("key1", "value1bis"),
                new KeyValuePair <string, string>("key3", "value3"),
            });
        }
コード例 #2
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        private static void AssertAreEqual(PropertySet expected, PropertySet actual)
        {
            Assert.AreEqual(expected.Count, actual.Count);

            foreach (KeyValuePair <string, string> entry in expected)
            {
                Assert.IsTrue(actual.Contains(entry));
            }
        }
コード例 #3
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void Copy()
        {
            PropertySet original = new PropertySet();

            original.Add("abc", "123");
            original.Add("def", "");

            PropertySet copy = original.Copy();

            Assert.AreNotSame(original, copy);
            AssertAreEqual(original, copy);
        }
コード例 #4
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void AsReadOnly()
        {
            PropertySet original = new PropertySet();

            original.Add("abc", "123");

            PropertySet readOnly = original.AsReadOnly();

            Assert.IsTrue(readOnly.IsReadOnly);
            AssertAreEqual(original, readOnly);

            MbUnit.Framework.Assert.Throws <NotSupportedException>(delegate { readOnly.Add("def", "456"); });
        }
コード例 #5
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void SerializeToXml(string expectedXml, string[] keyValuePairs)
        {
            PropertySet map = new PropertySet();

            for (int i = 0; i < keyValuePairs.Length; i += 2)
            {
                map.Add(keyValuePairs[i], keyValuePairs[i + 1]);
            }

            StringWriter writer = new StringWriter();

            serializer.Serialize(writer, map);

            Assert.AreEqual(expectedXml, writer.ToString());
        }
コード例 #6
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void DeserializeFromXml_RegressionTestForEmptyMetadataElement()
        {
            MetadataContainer container = new MetadataContainer();

            container.Metadata         = new PropertySet();
            container.FollowingElement = 1;

            XmlSerializer serializer = new XmlSerializer(typeof(MetadataContainer));
            StringWriter  output     = new StringWriter();

            serializer.Serialize(output, container);

            MetadataContainer result = (MetadataContainer)serializer.Deserialize(new StringReader(output.ToString()));

            Assert.Count(0, result.Metadata);
            Assert.AreEqual(1, result.FollowingElement);
        }
コード例 #7
0
ファイル: PropertySetTest.cs プロジェクト: citizenmatt/gallio
        public void GetAndSetValue()
        {
            PropertySet set = new PropertySet();

            Assert.IsNull(set.GetValue("key"));

            set.SetValue("key", "value");
            Assert.AreEqual("value", set.GetValue("key"));

            set.SetValue("key", "different value");
            Assert.AreEqual("different value", set.GetValue("key"));

            set.SetValue("key", null);
            Assert.IsNull(set.GetValue("key"));

            set.Add("key", "value1");
            Assert.AreEqual("value1", set.GetValue("key"));
        }
コード例 #8
0
ファイル: PropertyBagTest.cs プロジェクト: soelske/mbunit-v3
        public void GetAndSetValue()
        {
            PropertyBag bag = new PropertyBag();

            Assert.IsNull(bag.GetValue("key"));

            bag.SetValue("key", "value");
            Assert.AreEqual("value", bag.GetValue("key"));

            bag.SetValue("key", "different value");
            Assert.AreEqual("different value", bag.GetValue("key"));

            bag.SetValue("key", null);
            Assert.IsNull(bag.GetValue("key"));

            bag.Add("key", "value1");
            bag.Add("key", "value2");
            Assert.AreEqual("value1", bag.GetValue("key"));
            Assert.AreElementsEqual(new[] { "value1", "value2" }, bag["key"]);

            bag.SetValue("key", "value");
            Assert.AreElementsEqual(new[] { "value" }, bag["key"]);
        }
コード例 #9
0
        private void AssertNoVerificationErrors()
        {
            if (testData.VerificationErrors.Count == 0)
            {
                return;
            }

            var i = 1;

            TestLog.BeginMarker(Marker.AssertionFailure);
            foreach (var error in testData.VerificationErrors)
            {
                TestLog.Failures.BeginSection("ElementVerification Error " + i);
                TestLog.Failures.WriteLine(error.errorText);
                if (Config.Settings.reportSettings.screenshotOnError && (error.screenshot != null))
                {
                    TestLog.Failures.EmbedImage(null, error.screenshot);
                }
                TestLog.Failures.End();
                i++;
            }
            TestLog.End();
            Assert.TerminateSilently(TestOutcome.Failed);
        }
コード例 #10
0
        public void doStuffTest()
        {
            Form1 target = new Form1();

            Assert.IsTrue(target.doStuff());
        }