Ejemplo n.º 1
0
        public void DoesNotMatchWhenIndexerIsNotExpectedToBeEqual()
        {
            var expectedErrorMessage = "Default indexer accepting arguments < 21.0d > was not found on NUnit.Framework.Constraints.IndexerConstraintTests+IndexerTester.";

            var tester = new IndexerTester();

            var ex = Assert.Throws <ArgumentException>(() => Assert.That(tester, Has.No.ItemAt(21d).EqualTo("Should Throw")));

            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));
        }
Ejemplo n.º 2
0
        public void DoesNotMatchMissingIndexerEquality()
        {
            var expectedErrorMessage = $"  Expected string length 14 but was 13. Strings differ at index 0.{NL}  Expected: \"Second indexer\"{NL}  But was:  \"Third indexer\"{NL}  -----------^{NL}";

            var tester = new IndexerTester();

            var ex = Assert.Throws <AssertionException>(() => Assert.That(tester, Has.ItemAt(4, 2).EqualTo("Second indexer")));

            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));
        }
Ejemplo n.º 3
0
        public void DoesNotMatchWhenIndexerValueIsNotExpectedToBeEqual()
        {
            var expectedErrorMessage = $"  Expected: not Default indexer accepting arguments < <string.Empty> > equal to \"Second indexer\"{NL}  But was:  \"Second indexer\"{NL}";

            var tester = new IndexerTester();

            var ex = Assert.Throws <AssertionException>(() => Assert.That(tester, Has.No.ItemAt(string.Empty).EqualTo("Second indexer")));

            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));
        }
Ejemplo n.º 4
0
        public void CanMatchIndexerEquality()
        {
            var tester = new IndexerTester();

            Assert.That(tester, Has.ItemAt(42).EqualTo("Answer to the Ultimate Question of Life, the Universe, and Everything"));
            Assert.That(tester, Has.ItemAt(41).EqualTo("Still calculating").And.ItemAt(42).EqualTo("Answer to the Ultimate Question of Life, the Universe, and Everything"));

            Assert.That(tester, Has.ItemAt(string.Empty).EqualTo("Second indexer"));
            Assert.That(tester, Has.ItemAt(1, 2).EqualTo("Third indexer"));
            Assert.That(tester, Has.No.ItemAt(string.Empty).EqualTo("Third indexer"));
        }