Exemple #1
0
        public void SomeItemTests()
        {
            object[] mixed   = new object[] { 1, 2, "3", null, "four", 100 };
            object[] strings = new object[] { "abc", "bad", "cab", "bad", "dad" };

            // Not available using the classic syntax

            // Constraint Syntax
            Assert.That(mixed, Has.Some.Null);
            Assert.That(mixed, Has.Some.InstanceOf(typeof(int)));
            Assert.That(mixed, Has.Some.InstanceOf(typeof(string)));
            Assert.That(strings, Has.Some.StartsWith("ba"));
            Assert.That(strings, Has.Some.Not.StartsWith("ba"));

            // Inherited syntax
            Expect(mixed, Some.Null);
            Expect(mixed, Some.InstanceOf(typeof(int)));
            Expect(mixed, Some.InstanceOf(typeof(string)));
            Expect(strings, Some.StartsWith("ba"));
            Expect(strings, Some.Not.StartsWith("ba"));
        }