Пример #1
0
        public void CanMatchHidingNamedIndexer()
        {
            var tester = new DerivedClassWithoutNamedIndexer();

            Assert.That(tester, Has.ItemAt(42).EqualTo("New value for Named Int Indexer"));
            Assert.That(tester, Has.ItemAt(42, 43).EqualTo("A Named Int Int Indexer"));
        }
Пример #2
0
        public void CanMatchArrayEquality()
        {
            var tester = new[] { 1, 2, 3 };

            Assert.That(tester, Has.ItemAt(0).EqualTo(1));
            Assert.That(tester, Has.ItemAt(2).EqualTo(3));
        }
Пример #3
0
        public void CanMatchNamedIndexer()
        {
            var tester = new NamedIndexTester();

            Assert.That(tester, Has.ItemAt(42).EqualTo("A Named Int Indexer"));
            Assert.That(tester, Has.ItemAt(42, 43).EqualTo("A Named Int Int Indexer"));
        }
Пример #4
0
        public void CanMatchHidingIndexer()
        {
            var tester = new DerivedClassWithoutIndexer();

            Assert.That(tester, Has.ItemAt(string.Empty).EqualTo("New value for Second indexer"));
            Assert.That(tester, Has.ItemAt(1, 2).EqualTo("New value for Third indexer"));
            Assert.That(tester, Has.ItemAt(41).EqualTo("Still calculating"));
        }
Пример #5
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));
        }
Пример #6
0
        public void CanMatchArrayWithMultiDimensionsEquality()
        {
            var tester = new[, , , ] {
                { { { 1 }, { 2 }, { 3 } }, { { 4 }, { 5 }, { 6 } } },
                { { { 7 }, { 8 }, { 9 } }, { { 10 }, { 11 }, { 12 } } }
            };

            Assert.That(tester, Has.ItemAt(0, 0, 0, 0).EqualTo(1));
            Assert.That(tester, Has.ItemAt(1, 1, 2, 0).EqualTo(12));
        }
Пример #7
0
            public void HasASizeLimit()
            {
                var n    = MinLinesGeneratingMoreThan256Bytes();
                var text = Lines(Enumerable.Repeat(new string('a', 19), n));

                var actual = Dialog.Simple(text);

                Assert.That(actual, Has.Length.EqualTo(256));
                Assert.That(actual, Has.ItemAt(255).EqualTo(DialogEnd));
            }
Пример #8
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"));
        }
Пример #9
0
        public void CanMatchGenericIndexer()
        {
            var tester = new GenericIndexerTester <int>(100);

            Assert.That(tester, Has.ItemAt(42).EqualTo(100));
        }