Exemple #1
0
        public void Retrieve_NonTerminalDescriptor_DataOfTheTerminalDescriptorsThatComposeIt()
        {
            var terminalDescriptors =
                ArraysHelper.CreateWithContent(
                    new Mock <ITerminalDescriptor>().Object,
                    new Mock <ITerminalDescriptor>().Object,
                    new Mock <ITerminalDescriptor>().Object
                    );
            var data = new IData[terminalDescriptors.Length];

            for (var i = 0; i < terminalDescriptors.Length; ++i)
            {
                var terminalDescriptor = terminalDescriptors[i];
                var dataItem           = new Mock <IData>().Object;

                TestInstanceMock
                .Setup <IData>(_ => _.Retrieve(terminalDescriptor))
                .Returns(dataItem);

                data[i] = dataItem;
            }

            CompositionsMock
            .Setup(_ => _.Retrieve(NonTerminalDescriptor))
            .Returns(() => terminalDescriptors);

            var result = TestInstance.Retrieve(NonTerminalDescriptor);

            Assert.IsTrue(data.Equivalent(result));
        }
Exemple #2
0
        public void Contains_NonTerminalNotContained_False()
        {
            CompositionsMock
            .Setup(_ => _.Contains(NonTerminalDescriptor))
            .Returns(false);

            var result = TestInstance.Contains(NonTerminalDescriptor);

            Assert.IsFalse(result);
        }
Exemple #3
0
        public void RetrieveAllDescriptors__NonTerminalDescriptorsRetrieved()
        {
            var nonTerminalDescriptorMocks = ArraysHelper.CreateWithContent(new Mock <INonTerminalDescriptor>(), new Mock <INonTerminalDescriptor>());
            var nonTerminalDescriptors     = nonTerminalDescriptorMocks.Select(_ => _.Object);

            DataStoreMock.Setup(_ => _.RetrieveDescriptors()).Returns(new ITerminalDescriptor[0]);
            CompositionsMock.Setup(_ => _.RetrieveDescriptors()).Returns(nonTerminalDescriptors).Verifiable();

            var result = (IEnumerable <IDescriptor>)ReflectionHelper.Invoke(TestInstance, "RetrieveAllDescriptors");

            CompositionsMock.Verify();
            Assert.IsTrue(nonTerminalDescriptors.Equivalent(result));
        }
Exemple #4
0
        public void UpdateCompositionAndProvideAdditions__ProxiesNonTerminalDescriptorCompositionsStore()
        {
            var additions = ArraysHelper.CreateWithContent(new Mock <ITerminalDescriptor>().Object, new Mock <ITerminalDescriptor>().Object);

            CompositionsMock
            .Setup(_ => _.UpdateAndProvideAdditions(NonTerminalDescriptor, TerminalDescriptorsCollection))
            .Returns(additions)
            .Verifiable();

            var result = TestInstance.UpdateCompositionAndProvideAdditions(NonTerminalDescriptor, TerminalDescriptorsCollection);

            CompositionsMock.Verify();
            Assert.AreSame(additions, result);
        }