Ejemplo n.º 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"))));
        }
Ejemplo n.º 2
0
        public void WriteActualValueTo_FailureExist_FailureRenderActualCalled()
        {
            //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.RenderActual() == "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.WriteActualValueTo(writer);

            //Test conclusion
            Mock.Get(mockedFailure).Verify(f => f.RenderActual());
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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>()));
        }
Ejemplo n.º 5
0
        public void WriteActualValueTo_FailureExist_FailureRenderActualCalled()
        {
            //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.RenderActual() == "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.WriteActualValueTo(writer);

            //Test conclusion
            Mock.Get(mockedFailure).Verify(f => f.RenderActual());
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
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>()));
        }
Ejemplo n.º 8
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"))));
        }