示例#1
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);
        }
示例#2
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"));
        }
        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);
        }
        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);
        }
示例#5
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);
        }
        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, 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"));
        }
        public void Matches_ActualSubsetOfExpectation_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.Add("New perspective");
            var ctr = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
示例#8
0
 public static NBiStructure.EquivalentToConstraint ExactlyItems(IEnumerable<string> values)
 {
     var ctr = new NBiStructure.EquivalentToConstraint(values);
     return ctr;
 }
示例#9
0
文件: Has.cs 项目: ywscr/NBi
        public static NBiStructure.EquivalentToConstraint ExactlyItems(IEnumerable <string> values)
        {
            var ctr = new NBiStructure.EquivalentToConstraint(values);

            return(ctr);
        }