コード例 #1
0
        public void Matches_SqlQueryAndMembers_Succesful()
        {
            var command = new SqlCommand();

            command.Connection  = new SqlConnection(ConnectionStringReader.GetSqlClient());
            command.CommandText = "select " +
                                  "'Executive General and Administration' union select " +
                                  "'Inventory Management' union select " +
                                  "'Manufacturing' union select " +
                                  "'Research and Development' union select " +
                                  "'Quality Assurance' union select " +
                                  "'Sales and Marketing' ";

            var discovery = new DiscoveryRequestFactory().Build(
                ConnectionStringReader.GetAdomd()
                , "Corporate"
                , "Adventure Works"
                , "Department"
                , "Departments"
                , null);

            var ctr = new EquivalentToConstraint(command);

            Assert.That(discovery, ctr);
        }
コード例 #2
0
        public void Matches_SqlQueryAndMembers_Succesful()
        {
            var sql = "select " +
                      "'Executive General and Administration' union select " +
                      "'Inventory Management' union select " +
                      "'Manufacturing' union select " +
                      "'Research and Development' union select " +
                      "'Quality Assurance' union select " +
                      "'Sales and Marketing' ";
            var args     = new QueryResultSetResolverArgs(new QueryResolverArgs(sql, ConnectionStringReader.GetSqlClient(), null, null, new TimeSpan(0, 0, 30), System.Data.CommandType.Text));
            var factory  = new ResultSetResolverFactory(new ServiceLocator());
            var resolver = factory.Instantiate(args);

            var discovery = new DiscoveryRequestFactory().Build(
                ConnectionStringReader.GetAdomd()
                , "Corporate"
                , "Adventure Works"
                , "Department"
                , "Departments"
                , null);

            var ctr = new EquivalentToConstraint(resolver);

            Assert.That(discovery, ctr);
        }
コード例 #3
0
        public void WriteTo_FailingAssertionForListOfLevels_TextContainsFewKeyInfo()
        {
            var exp     = new string[] { "Expected level 1", "Expected level 2" };
            var request = new DiscoveryRequestFactory().BuildDirect(
                "connectionString",
                DiscoveryTarget.Levels,
                new List <IFilter>()
            {
                new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)
                , new CaptionFilter("dimension-caption", DiscoveryTarget.Dimensions)
                , new CaptionFilter("hierarchy-caption", DiscoveryTarget.Hierarchies)
            });


            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 factoryStub = new Mock <AdomdDiscoveryCommandFactory>();

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

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

            //Method under test
            string assertionText = null;

            try
            {
                Assert.That(request, containsConstraint);
            }
            catch (AssertionException ex)
            {
                assertionText = ex.Message;
            }

            //Test conclusion
            Assert.That(assertionText, Is.StringContaining("exact").And
                        .StringContaining("perspective-name").And
                        .StringContaining("dimension-caption").And
                        .StringContaining("hierarchy-caption").And
                        .StringContaining("levels").And
                        .StringContaining("Expected level 1").And
                        .StringContaining("Expected level 2"));
        }
コード例 #4
0
        public void Matches_ActualEqualToExpectation_Success()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                ConnectionStringReader.GetAdomd()
                , DiscoveryTarget.Perspectives
                , new List <IFilter>());

            var expected = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Sales Summary", "Sales Targets" };
            var ctr      = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(discovery, ctr);
        }
コード例 #5
0
        public void WriteTo_FailingAssertionForListOfLevels_TextContainsFewKeyInfo()
        {
            var exp = new string[] { "Expected member 1", "Expected member 2" };
            var cmd = new DiscoveryRequestFactory().Build(
                "connectionString",
                "member-caption",
                "perspective-name",
                "dimension-caption", "hierarchy-caption", null);


            var memberStub = new Mock <NBi.Core.Analysis.Member.Member>();
            var member1    = memberStub.Object;
            var member2    = memberStub.Object;
            var members    = new MemberResult();

            members.Add(member1);
            members.Add(member2);

            var meMock = new Mock <MembersAdomdEngine>();

            meMock.Setup(engine => engine.GetMembers(cmd))
            .Returns(members);
            var me = meMock.Object;

            var equivalentConstraint = new EquivalentToConstraint(exp)
            {
                MembersEngine = me
            };

            //Method under test
            string assertionText = null;

            try
            {
                Assert.That(cmd, equivalentConstraint);
            }
            catch (AssertionException ex)
            {
                assertionText = ex.Message;
            }

            //Test conclusion
            Assert.That(assertionText, Is.StringContaining("perspective-name").And
                        .StringContaining("dimension-caption").And
                        .StringContaining("hierarchy-caption").And
                        .StringContaining("equivalent to").And
                        .StringContaining("Expected member 1").And
                        .StringContaining("Expected member 2"));
        }
コード例 #6
0
        public void Matches_ActualEqualToExpectationButCaseNonMatching_Failure()
        {
            var provider  = new StructureDiscoveryFactoryProvider();
            var factory   = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                Target.Perspectives
                , TargetType.Object
                , new CaptionFilter[] { });

            var expected = new string[] { "Adventure Works".ToLower(), "Channel Sales".ToUpper(), "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };
            var ctr      = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
コード例 #7
0
        public void Matches_ActualEqualToExpectation_Success()
        {
            var provider  = new StructureDiscoveryFactoryProvider();
            var factory   = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                Target.Perspectives
                , TargetType.Object
                , new CaptionFilter[] {});

            var expected = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Sales Summary", "Sales Targets" };
            var ctr      = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(discovery, ctr);
        }
コード例 #8
0
        public void Matches_ActualSubsetOfExpectation_Failure()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                ConnectionStringReader.GetAdomd()
                , DiscoveryTarget.Perspectives
                , new List <IFilter>());

            var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };
            var expected        = new List <string>();

            expected.AddRange(expectedStrings);
            expected.Add("New perspective");
            var ctr = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
コード例 #9
0
        public void WriteTo_FailingAssertionForListOfLevels_TextContainsFewKeyInfo()
        {
            var exp = new string[] { "Expected level 1", "Expected level 2" };

            var description = new CommandDescription(
                Target.Levels,
                new CaptionFilter[]
            {
                new CaptionFilter(Target.Perspectives, "perspective-name")
                , new CaptionFilter(Target.Dimensions, "dimension-caption")
                , new CaptionFilter(Target.Hierarchies, "hierarchy-caption")
            });


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

            var commandStub = new Mock <IStructureDiscoveryCommand>();

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

            var containsConstraint = new EquivalentToConstraint(exp);

            //Method under test
            string assertionText = null;

            try
            {
                Assert.That(commandStub.Object, containsConstraint);
            }
            catch (AssertionException ex)
            {
                assertionText = ex.Message;
            }

            //Test conclusion
            Assert.That(assertionText, Does.Contain("exact").And
                        .StringContaining("perspective-name").And
                        .StringContaining("dimension-caption").And
                        .StringContaining("hierarchy-caption").And
                        .StringContaining("levels").And
                        .StringContaining("Expected level 1").And
                        .StringContaining("Expected level 2"));
        }
コード例 #10
0
        public void Matches_ActualMoreThanExpectation_Failure()
        {
            var provider  = new StructureDiscoveryFactoryProvider();
            var factory   = provider.Instantiate(ConnectionStringReader.GetAdomd());
            var discovery = factory.Instantiate(
                Target.Perspectives
                , TargetType.Object
                , new CaptionFilter[] { });

            var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };
            var expected        = new List <string>();

            expected.AddRange(expectedStrings);
            expected.RemoveAt(0);
            var ctr = new EquivalentToConstraint(expected);

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