예제 #1
0
        public void Append_adds_item_to_end_of_sequence()
        {
            var result = new[] { 1, 2 }.Append(3);

            Assert.Equal(3, result.Count());
            Assert.Equal(1, result.First());
            Assert.Equal(3, result.Last());
        }
예제 #2
0
        public void Prepend_adds_item_to_beginning_of_sequence()
        {
            var result = new[] { 2, 3 }.Prepend(1);

            Assert.Equal(3, result.Count());
            Assert.Equal(1, result.First());
            Assert.Equal(3, result.Last());
        }
        public void when_using_a_visitor()
        {
            //setup
            var controller = new PropertyBagVersionController<FlatPropertyBag>(TestHelper.CreateWithNonDefaultProperties<FlatPropertyBag>(), 
                                                                               _testHelper.MakeConfiguredCloneFactoryFor<FlatPropertyBag>(),
                                                                               _testHelper.EmptyChangeSet(),
                                                                               _testHelper.MakeConfiguredVisitorFactory(),
                                                                               _testHelper.MakeConfiguredProxyFactory());

            var fakeChildren = new[] {A.Fake<IVersionControlNode>(), A.Fake<IVersionControlNode>()};
            var fakeVisitor = A.Fake<IVersionControlTreeVisitor>();
            controller.Children.AddRange(fakeChildren);

            //act
            controller.Accept(fakeVisitor);

            //assert
            A.CallTo(() => fakeChildren.First().RecursiveAccept(fakeVisitor)).MustHaveHappened();
            A.CallTo(() => fakeChildren.Last().RecursiveAccept(fakeVisitor)).MustHaveHappened();
            A.CallTo(() => fakeVisitor.OnEntry(controller)).MustHaveHappened();
        }
예제 #4
0
        public void should_get_last_element_using_last()
        {
            var sequence = new[] { 1, 2, 3, 4, 5 };

            int lastElement = sequence.Last();
            int lastEvenNumber = sequence.Last(item => item % 2 == 0);

            // please update variable values for the following 2 lines to fix the test.
            const int expectedLastElement = 0;
            const int expectedLastEvenNumber = 0;

            Assert.Equal(expectedLastElement, lastElement);
            Assert.Equal(expectedLastEvenNumber, lastEvenNumber);
        }