Beispiel #1
0
        public void Matches_GivenDiscoveryRequest_CommandCalledOnceWithParametersComingFromDiscoveryCommand()
        {
            var exp = "Expected measure";
            var request = new DiscoveryRequestFactory().BuildDirect(
                        "connectionString",
                        DiscoveryTarget.MeasureGroups,
                        new List<IFilter>()
                            {
                                new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)
                                , new CaptionFilter("measure-group", DiscoveryTarget.MeasureGroups)
                        });

            var elStub = new Mock<IField>();
            var el1 = elStub.Object;
            var el2 = elStub.Object;
            var elements = new List<IField>();
            elements.Add(el1);
            elements.Add(el2);

            var commandMock = new Mock<AdomdDiscoveryCommand>("connectionString");
            commandMock.Setup(f => f.Execute())
                .Returns(elements);

            var factoryStub = new Mock<AdomdDiscoveryCommandFactory>();
            factoryStub.Setup(f => f.BuildExact(request))
                .Returns(commandMock.Object);
            var factory = factoryStub.Object;

            var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };

            //Method under test
            containsConstraint.Matches(request);

            //Test conclusion
            commandMock.Verify(c => c.Execute(), Times.Once());
        }
        public void Matches_GivenCommand_CommandExecuteCalledOnce()
        {
            var exp = "Expected hierarchy";
            var description = new CommandDescription(Target.Hierarchies,
                        new CaptionFilter[]
                            {
                                new CaptionFilter(Target.Perspectives, "perspective-name")
                                , new CaptionFilter(Target.Dimensions, "dimension-caption")
                        });

            var actuals = new string[] { "Actual hierarchy 1" };

            var commandMock = new Mock<IStructureDiscoveryCommand>();
            commandMock.Setup(cmd => cmd.Execute()).Returns(actuals);
            commandMock.Setup(cmd => cmd.Description).Returns(description);

            var containsConstraint = new ContainConstraint(exp) {};

            //Method under test
            containsConstraint.Matches(commandMock.Object);

            //Test conclusion
            commandMock.Verify(cmd => cmd.Execute(), Times.Once());
        }
        public void Matches_ExpectedNotContainedInActual_Failure()
        {
            var provider = new StructureDiscoveryFactoryProvider();
            var factory = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                        Target.Perspectives
                        , TargetType.Object
                        , new CaptionFilter[] { });

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
        public void ContainConstraint_FindNonExistingMeasure_Failure()
        {
            var provider = new StructureDiscoveryFactoryProvider();
            var factory = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                        Target.Measures
                        , TargetType.Object
                        , new CaptionFilter[] {
                                new CaptionFilter(Target.Perspectives, "Adventure Works")
                                , new CaptionFilter(Target.MeasureGroups, "Reseller Orders")
                        });

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
        public void ContainConstraint_FindNonExistingLevel_Failure()
        {
            var provider = new StructureDiscoveryFactoryProvider();
            var factory = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                        Target.Levels
                        , TargetType.Object
                        , new CaptionFilter[] {
                                new CaptionFilter(Target.Perspectives, "Adventure Works")
                                , new CaptionFilter(Target.Dimensions, "Product")
                                , new CaptionFilter(Target.Hierarchies, "Customer Geography")
                        });

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
Beispiel #6
0
        public void Matches_ExpectedNotContainedInActual_Failure()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                        ConnectionStringReader.GetAdomd()
                        , DiscoveryTarget.Perspectives
                        , new List<IFilter>());

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
Beispiel #7
0
        public void ContainConstraint_FindNonExistingMeasure_Failure()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                         ConnectionStringReader.GetAdomd()
                         , DiscoveryTarget.Measures
                         , new List<IFilter>()
                            {
                                new CaptionFilter("Adventure Works", DiscoveryTarget.Perspectives)
                                , new CaptionFilter("Reseller Orders", DiscoveryTarget.MeasureGroups)
                        });

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
Beispiel #8
0
        public void ContainConstraint_FindNonExistingLevel_Failure()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                        ConnectionStringReader.GetAdomd()
                        , DiscoveryTarget.Levels
                        , new List<IFilter>()
                            {
                                new CaptionFilter("Adventure Works", DiscoveryTarget.Perspectives)
                                , new CaptionFilter("Customer", DiscoveryTarget.Dimensions)
                                , new CaptionFilter("Customer Geography", DiscoveryTarget.Hierarchies)
                        });

            var ctr = new ContainConstraint("Not existing");

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }