Beispiel #1
0
        public void UpdateAndProvideAdditions__CompositionUpdated()
        {
            TestInstanceMockProtected
            .Setup("CompareToInitialCompositionAndFindAdditions", ItExpr.IsAny <INonTerminalDescriptor>(), ItExpr.IsAny <IEnumerable <ITerminalDescriptor> >());
            TestInstanceMock
            .Setup(_ => _.Update(Descriptor, Composition))
            .Verifiable();

            TestInstance.UpdateAndProvideAdditions(Descriptor, Composition);

            TestInstanceMock.Verify();
        }
Beispiel #2
0
        public void UpdateAndProvideAdditions__AdditionsCorrectlyComputedAndResultProxied()
        {
            var additions = new Mock <IEnumerable <ITerminalDescriptor> >().Object;

            TestInstanceMock
            .Setup(_ => _.Update(It.IsAny <INonTerminalDescriptor>(), It.IsAny <IEnumerable <ITerminalDescriptor> >()));
            TestInstanceMockProtected
            .Setup <IEnumerable <ITerminalDescriptor> >("CompareToInitialCompositionAndFindAdditions", Descriptor, Composition)
            .Returns(additions)
            .Verifiable();

            var result = TestInstance.UpdateAndProvideAdditions(Descriptor, Composition);

            TestInstanceMock.Verify();
            Assert.AreSame(additions, result);
        }
Beispiel #3
0
        public void UpdateAndProvideAdditions__AdditionsComputedBeforeUpdating()
        {
            var callCounter = 0;
            var CompareToInitialCompositionAndFindAdditionsCallNumber = 0;
            var updateCallNumber = 0;

            TestInstanceMockProtected
            .Setup("CompareToInitialCompositionAndFindAdditions", ItExpr.IsAny <INonTerminalDescriptor>(), ItExpr.IsAny <IEnumerable <ITerminalDescriptor> >())
            .Callback(() => CompareToInitialCompositionAndFindAdditionsCallNumber = ++callCounter);
            TestInstanceMock
            .Setup(_ => _.Update(It.IsAny <INonTerminalDescriptor>(), It.IsAny <IEnumerable <ITerminalDescriptor> >()))
            .Callback(() => updateCallNumber = ++callCounter);

            TestInstance.UpdateAndProvideAdditions(Descriptor, Composition);

            if (0 != updateCallNumber)
            {
                Assert.IsTrue(CompareToInitialCompositionAndFindAdditionsCallNumber <= updateCallNumber);
            }
        }
Beispiel #4
0
        public void CompareToInitialCompositionAndFindAdditions_Descriptor_ReturnsAdditionsOfTheNewCompositionOverTheInitialOne()
        {
            var initialComposition = new Mock <IEnumerable <ITerminalDescriptor> >().Object;
            var newComposition     = new Mock <IEnumerable <ITerminalDescriptor> >().Object;
            var additions          = new Mock <IEnumerable <ITerminalDescriptor> >().Object;

            TestInstanceMockProtected
            .Setup <IEnumerable <ITerminalDescriptor> >("FindDistinctAdditions", initialComposition, newComposition)
            .Returns(additions)
            .Verifiable();

            TestInstanceMock
            .Setup(_ => _.Retrieve(Descriptor))
            .Returns(initialComposition)
            .Verifiable();

            var result = ReflectionHelper.Invoke(TestInstance, "CompareToInitialCompositionAndFindAdditions", Descriptor, newComposition);

            Assert.AreSame(additions, result);
        }