コード例 #1
0
        public void Matches_GivenDiscoveryRequest_CommandCalledOnce()
        {
            var request = new DiscoveryRequestFactory().BuildDirect(
                "connectionString",
                DiscoveryTarget.MeasureGroups,
                new List <IFilter>()
            {
                new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)
                , new CaptionFilter("measure-group", DiscoveryTarget.MeasureGroups)
                , new CaptionFilter("measure", DiscoveryTarget.Measures)
            });


            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 ctr = new ExistsConstraint()
            {
                CommandFactory = factory
            };

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

            //Test conclusion
            commandMock.Verify(c => c.Execute(), Times.Once());
        }
コード例 #2
0
        public void Matches_GivenDiscoveryRequest_FactoryCalledOnceWithParametersComingFromRequest()
        {
            var request = new DiscoveryRequestFactory().BuildDirect(
                "connectionString",
                DiscoveryTarget.Dimensions,
                new List <IFilter>()
            {
                new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)
                , new CaptionFilter("expected-dimension-caption", DiscoveryTarget.Dimensions)
            });

            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 commandStub = new Mock <AdomdDiscoveryCommand>("connectionString");

            commandStub.Setup(f => f.Execute())
            .Returns(elements);

            var factoryMock = new Mock <AdomdDiscoveryCommandFactory>();

            factoryMock.Setup(f => f.BuildExact(request))
            .Returns(commandStub.Object);
            var factory = factoryMock.Object;

            var ctr = new ExistsConstraint()
            {
                CommandFactory = factory
            };

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

            //Test conclusion
            factoryMock.Verify(f => f.BuildExact(request), Times.Once());
        }
コード例 #3
0
        public void Matches_GivenCommand_ExecuteCalledOnce()
        {
            var description = new CommandDescription(Target.Dimensions,
                                                     new CaptionFilter[]
            {
                new CaptionFilter(Target.Perspectives, "perspective-name")
            });

            var actuals = new string[] { "Actual dimension 1", "Actual dimension 2", "Actual dimension 3" };

            var commandMock = new Mock <IStructureDiscoveryCommand>();

            commandMock.Setup(cmd => cmd.Execute()).Returns(actuals);
            commandMock.Setup(cmd => cmd.Description).Returns(description);

            var existConstraint = new ExistsConstraint("expected-dimension-caption");

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

            //Test conclusion
            commandMock.Verify(cmd => cmd.Execute(), Times.Once());
        }