예제 #1
0
        public void WriteActualValueTo_OneCaptionNotContainedInMoreThan15Members_DisplayOnlyFirstMembers()
        {
            //Mock the writer
            var mockWriter = new Mock <global::NUnit.Framework.Constraints.MessageWriter>();
            var writer     = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();

            for (int i = 0; i < 25; i++)
            {
                members.Add(new NBi.Core.Analysis.Member.Member(string.Format("[Hierarchy].[member {0}]", i), string.Format("member {0}", i), i, 0));
            }

            var containConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List <string>()
            {
                "First member"
            });

            //Call the method to test
            containConstraint.Matches(members);
            containConstraint.WriteActualValueTo(writer);

            //Test conclusion
            var shortList = members.Take(10);

            mockWriter.Verify(wr => wr.WriteActualValue(shortList));
            mockWriter.Verify(wr => wr.WriteActualValue(It.Is <string>(str => str.Contains("15") && str.Contains("other"))));
        }
예제 #2
0
        public void Matches_OneCaptionContainedInMembers_Validated()
        {
            //Buiding object used during test
            var members = new MemberResult();
            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List<string>() {"First member", "Second Member"});

            //Call the method to test
            var res = subsetOfConstraint.Matches(members);

            //Test conclusion
            Assert.That(res, Is.True);
        }
예제 #3
0
        public void Matches_OneCaptionContainedInMembers_Validated()
        {
            //Buiding object used during test
            var members = new MemberResult();

            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List <string>()
            {
                "First member", "Second Member"
            });

            //Call the method to test
            var res = subsetOfConstraint.Matches(members);

            //Test conclusion
            Assert.That(res, Is.True);
        }
예제 #4
0
        public void WriteDescriptionTo_FailureExist_FailureRenderExpectedCalled()
        {
            //Stub the writer
            var stubWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();
            var writer = stubWriter.Object;

            //Mock the failure
            var mockedFailure = Mock.Of<ItemsMessage>(f => f.RenderExpected() == "failure actual");

            //Buiding object used during test
            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List<string>() { "First member" });
            subsetOfConstraint.Failure = mockedFailure;

            //Call the method to test
            subsetOfConstraint.WriteDescriptionTo(writer);

            //Test conclusion
            Mock.Get(mockedFailure).Verify(f => f.RenderExpected());
        }
예제 #5
0
        public void WriteActualValueTo_OneCaptionNotContainedInLessThan15Members_DisplayAllMembers()
        {
            //Mock the writer
            var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();
            var writer = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();
            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));
            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List<string>() { "First member" });

            //Call the method to test
            subsetOfConstraint.Matches(members);
            subsetOfConstraint.WriteActualValueTo(writer);

            //Test conclusion
            mockWriter.Verify(wr => wr.WriteActualValue(members));
        }
예제 #6
0
        public void WriteActualValueTo_OneCaptionNotContainedInZeroMembers_DisplayNothingFoundMessage()
        {
            //Mock the writer
            var mockWriter = new Mock <global::NUnit.Framework.Constraints.MessageWriter>();
            var writer     = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List <string>()
            {
                "First member"
            });

            //Call the method to test
            subsetOfConstraint.Matches(members);
            subsetOfConstraint.WriteActualValueTo(writer);

            //Test conclusion
            mockWriter.Verify(wr => wr.WriteActualValue(It.IsAny <NBi.NUnit.Member.SubsetOfConstraint.NothingFoundMessage>()));
        }
예제 #7
0
        public void WriteActualValueTo_OneCaptionNotContainedInMoreThan15Members_DisplayOnlyFirstMembers()
        {
            //Mock the writer
            var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();
            var writer = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();
            for (int i = 0; i < 25; i++)
                members.Add(new NBi.Core.Analysis.Member.Member(string.Format("[Hierarchy].[member {0}]", i), string.Format("member {0}", i), i, 0));

            var containConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List<string>() { "First member" });

            //Call the method to test
            containConstraint.Matches(members);
            containConstraint.WriteActualValueTo(writer);

            //Test conclusion
            var shortList = members.Take(10);
            mockWriter.Verify(wr => wr.WriteActualValue(shortList));
            mockWriter.Verify(wr => wr.WriteActualValue(It.Is<string>(str => str.Contains("15") && str.Contains("other"))));
        }
예제 #8
0
        public void WriteDescriptionTo_FailureExist_FailureRenderExpectedCalled()
        {
            //Stub the writer
            var stubWriter = new Mock <global::NUnit.Framework.Constraints.MessageWriter>();
            var writer     = stubWriter.Object;

            //Mock the failure
            var mockedFailure = Mock.Of <ItemsMessage>(f => f.RenderExpected() == "failure actual");

            //Buiding object used during test
            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List <string>()
            {
                "First member"
            });

            subsetOfConstraint.Failure = mockedFailure;

            //Call the method to test
            subsetOfConstraint.WriteDescriptionTo(writer);

            //Test conclusion
            Mock.Get(mockedFailure).Verify(f => f.RenderExpected());
        }
예제 #9
0
        public void WriteActualValueTo_OneCaptionNotContainedInLessThan15Members_DisplayAllMembers()
        {
            //Mock the writer
            var mockWriter = new Mock <global::NUnit.Framework.Constraints.MessageWriter>();
            var writer     = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();

            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));
            members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List <string>()
            {
                "First member"
            });

            //Call the method to test
            subsetOfConstraint.Matches(members);
            subsetOfConstraint.WriteActualValueTo(writer);

            //Test conclusion
            mockWriter.Verify(wr => wr.WriteActualValue(members));
        }
예제 #10
0
        public void WriteActualValueTo_OneCaptionNotContainedInZeroMembers_DisplayNothingFoundMessage()
        {
            //Mock the writer
            var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();
            var writer = mockWriter.Object;

            //Buiding object used during test
            var members = new MemberResult();

            var subsetOfConstraint = new NBi.NUnit.Member.SubsetOfConstraint(new List<string>() { "First member" });

            //Call the method to test
            subsetOfConstraint.Matches(members);
            subsetOfConstraint.WriteActualValueTo(writer);

            //Test conclusion
            mockWriter.Verify(wr => wr.WriteActualValue(It.IsAny<NBi.NUnit.Member.SubsetOfConstraint.NothingFoundMessage>()));
        }
예제 #11
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 containsConstraint = new SubsetOfConstraint(exp) { MembersEngine = me };

            //Method under test
            string assertionText = null;
            try
            {
                Assert.That(cmd, containsConstraint);
            }
            catch (AssertionException ex)
            {
                assertionText = ex.Message;
            }

            //Test conclusion
            Assert.That(assertionText, Is.StringContaining("set").And
                                            .StringContaining("perspective-name").And
                                            .StringContaining("dimension-caption").And
                                            .StringContaining("hierarchy-caption").And
                                            .StringContaining("Expected member 1").And
                                            .StringContaining("Expected member 2"));
        }