Exemplo n.º 1
0
        public void ShouldCreateNewVectorWithAlteredCell()
        {
            Vector <int> original = new ArrayVector <int>(1, 2, 3);

            original.ShouldList(1, 2, 3);
            original.With(0, 10).ShouldList(10, 2, 3);
            original.With(1, 20).ShouldList(1, 20, 3);
            original.With(2, 30).ShouldList(1, 2, 30);
            original.ShouldList(1, 2, 3);
        }
Exemplo n.º 2
0
        public void ShouldCreateNewVectorWithNewValueAppended()
        {
            Vector <int> original = new ArrayVector <int>(1, 2, 3);

            original.ShouldList(1, 2, 3);

            Vector <int> appended = original.Append(4);

            original.ShouldList(1, 2, 3);
            appended.ShouldList(1, 2, 3, 4);
        }
Exemplo n.º 3
0
        public void ShouldRemainImmutableEvenWhenSourceArrayIsMutated()
        {
            var          source = new[] { 1, 2 };
            Vector <int> vector = new ArrayVector <int>(source);

            vector.ShouldList(1, 2);

            source[0] = -1;
            source[1] = -2;

            vector.ShouldList(1, 2);
        }
Exemplo n.º 4
0
        public void ShouldBeEnumerable()
        {
            Vector <int> empty    = new ArrayVector <int>();
            Vector <int> nonempty = new ArrayVector <int>(1, 2, 3);

            empty.ShouldBeEmpty();
            nonempty.ShouldList(1, 2, 3);
        }
Exemplo n.º 5
0
        public void ShouldCreateSlices()
        {
            Vector <int> slice = new ArrayVector <int>(0, 1, 2, 3, 4, 5, 6).Slice(1, 6);

            slice.ShouldList(1, 2, 3, 4, 5);
        }