예제 #1
0
        public void GetLabels_returns_results_from_new_provider(IGetsLabels existingProvider,
                                                                IGetsLabels newProvider,
                                                                IParsesLabelNames nameParser,
                                                                Label newLabel)
        {
            // Arrange
            Mock.Get(existingProvider)
            .Setup(x => x.GetLabels(It.IsAny <IReadOnlyCollection <string> >()))
            .Returns(new Label[0]);
            Mock.Get(newProvider)
            .Setup(x => x.GetLabels(It.IsAny <IReadOnlyCollection <string> >()))
            .Returns(new [] { newLabel });
            var sut = new ExistingAndNewLabelProvider(existingProvider, newProvider, nameParser);

            // Act
            var result = sut.GetLabels(new [] { newLabel.Name });

            // Assert
            Assert.That(result, Has.Exactly(1).SameAs(newLabel));
        }
예제 #2
0
        public void GetLabels_passes_name_to_new_provider_if_it_does_not_have_an_existing_label(IGetsLabels existingProvider,
                                                                                                IGetsLabels newProvider,
                                                                                                IParsesLabelNames nameParser,
                                                                                                string labelName)
        {
            // Arrange
            Mock.Get(existingProvider)
            .Setup(x => x.GetLabels(It.IsAny <IReadOnlyCollection <string> >()))
            .Returns(new Label[0]);
            Mock.Get(newProvider)
            .Setup(x => x.GetLabels(It.IsAny <IReadOnlyCollection <string> >()))
            .Returns(new Label[0]);
            var sut = new ExistingAndNewLabelProvider(existingProvider, newProvider, nameParser);

            // Act
            sut.GetLabels(new [] { labelName });

            // Assert
            Mock.Get(newProvider)
            .Verify(x => x.GetLabels(It.Is <IReadOnlyCollection <string> >(c => c.Count == 1)), Times.Once);
        }