How to use Member class of NBi.Core.Analysis.Member package

Best NBi code snippet using NBi.Core.Analysis.Member.Member

ContainsConstraintTest.cs

Source:ContainsConstraintTest.cs Github

copy

Full Screen

1using Moq;2using System.Linq;3using NBi.Core.Analysis.Member;4using NBi.Core.Analysis.Request;5using NBi.NUnit.Member;6using NUnit.Framework;78namespace NBi.Testing.Unit.NUnit.Member9{10 [TestFixture]11 public class ContainsConstraintTest12 {13 [Test]14 public void Matches_GivenMemberCommand_EngineCalledOnceWithParametersComingFromMemberCommand()15 {16 var exp = "Expected member";17 var cmd = new DiscoveryRequestFactory().Build(18 "ConnectionString",19 "member-caption",20 "perspective",21 "dimension",22 null,23 null);2425 var memberStub = new Mock<NBi.Core.Analysis.Member.Member>();26 var member1 = memberStub.Object;27 var member2 = memberStub.Object;28 var members = new MemberResult();29 members.Add(member1);30 members.Add(member2);3132 var meMock = new Mock<MembersAdomdEngine>();33 meMock.Setup(engine => engine.GetMembers(cmd))34 .Returns(members);35 var me = meMock.Object;3637 var containsConstraint = new ContainConstraint(exp) { MembersEngine = me };3839 //Method under test40 containsConstraint.Matches(cmd);4142 //Test conclusion 43 meMock.Verify(engine => engine.GetMembers(cmd), Times.Once());44 }4546 [Test]47 public void WriteTo_FailingAssertionForChild_TextContainsFewKeyInfo()48 {49 var exp = "Expected member";50 var cmd = new DiscoveryRequestFactory().Build(51 "connectionString",52 "member-caption",53 "perspective-name",54 "dimension-caption",55 "hierarchy-caption",56 null);5758 var memberStub = new Mock<NBi.Core.Analysis.Member.Member>();59 var member1 = memberStub.Object;60 var member2 = memberStub.Object;61 var members = new MemberResult();62 members.Add(member1);63 members.Add(member2);6465 var meStub = new Mock<MembersAdomdEngine>();66 meStub.Setup(engine => engine.GetMembers(cmd))67 .Returns(members);68 var me = meStub.Object;6970 var containsConstraint = new ContainConstraint(exp) { MembersEngine = me };7172 //Method under test73 string assertionText = null;74 try75 {76 Assert.That(cmd, containsConstraint);77 }78 catch (AssertionException ex)79 {80 assertionText = ex.Message;81 }8283 //Test conclusion 84 Assert.That(assertionText, Is.StringContaining("perspective-name").And85 .StringContaining("dimension-caption").And86 .StringContaining("hierarchy-caption").And87 .StringContaining("child").And88 .StringContaining("Expected member"));8990 }9192 [Test]93 public void WriteTo_FailingAssertionForMember_TextContainsFewKeyInfo()94 {95 var exp = "Expected member";96 var cmd = new DiscoveryRequestFactory().Build(97 "connectionString",98 string.Empty,99 "perspective-name",100 "dimension-caption",101 "hierarchy-caption",102 "level-caption");103104 var memberStub = new Mock<NBi.Core.Analysis.Member.Member>();105 var member1 = memberStub.Object;106 var member2 = memberStub.Object;107 var members = new MemberResult();108 members.Add(member1);109 members.Add(member2);110111 var meStub = new Mock<MembersAdomdEngine>();112 meStub.Setup(engine => engine.GetMembers(cmd))113 .Returns(members);114 var me = meStub.Object;115116 var containsConstraint = new ContainConstraint(exp) { MembersEngine = me };117118 //Method under test119 string assertionText = null;120 try121 {122 Assert.That(cmd, containsConstraint);123 }124 catch (AssertionException ex)125 {126 assertionText = ex.Message;127 }128129 //Test conclusion 130 Assert.That(assertionText, Is.StringContaining("perspective-name").And131 .StringContaining("dimension-caption").And132 .StringContaining("hierarchy-caption").And133 .StringContaining("level-caption").And134 .StringContaining("member").And135 .StringContaining("Expected member"));136137 }138139140141 [Test]142 public void Matches_OneCaptionContainedInMembers_Validated()143 {144 //Buiding object used during test145 var members = new MemberResult();146 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));147 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));148149 var containConstraint = new NBi.NUnit.Member.ContainConstraint("First member");150151 //Call the method to test152 var res = containConstraint.Matches(members);153154 //Test conclusion 155 Assert.That(res, Is.True);156 }157158 [Test]159 public void Matches_OneCaptionNotContainedInMembers_Failure()160 {161 //Buiding object used during test162 var members = new MemberResult();163 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));164 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));165166 var containConstraint = new NBi.NUnit.Member.ContainConstraint("Third member");167168 //Call the method to test169 var res = containConstraint.Matches(members);170171 //Test conclusion 172 Assert.That(res, Is.False);173 }174175 [Test]176 public void WriteActualValueTo_OneCaptionNotContainedInLessThan15Members_DisplayAllMembers()177 {178 //Mock the writer179 var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();180 var writer = mockWriter.Object;181182 //Buiding object used during test183 var members = new MemberResult();184 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));185 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));186187 var containConstraint = new NBi.NUnit.Member.ContainConstraint("Third member");188189 //Call the method to test190 containConstraint.Matches(members);191 containConstraint.WriteActualValueTo(writer);192193 //Test conclusion 194 mockWriter.Verify(wr => wr.WriteActualValue(members));195 }196197 [Test]198 public void WriteActualValueTo_OneCaptionNotContainedInZeroMembers_DisplayNothingFoundMessage()199 {200 //Mock the writer201 var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();202 var writer = mockWriter.Object;203204 //Buiding object used during test205 var members = new MemberResult();206207 var containConstraint = new NBi.NUnit.Member.ContainConstraint("Third member");208209 //Call the method to test210 containConstraint.Matches(members);211 containConstraint.WriteActualValueTo(writer);212213 //Test conclusion 214 mockWriter.Verify(wr => wr.WriteActualValue(It.IsAny<NBi.NUnit.Member.ContainConstraint.NothingFoundMessage>()));215 }216217 [Test]218 public void WriteActualValueTo_OneCaptionNotContainedInMoreThan15Members_DisplayOnlyFirstMembers()219 {220 //Mock the writer221 var mockWriter = new Mock<global::NUnit.Framework.Constraints.MessageWriter>();222 var writer = mockWriter.Object;223224 //Buiding object used during test225 var members = new MemberResult();226 for (int i = 0; i < 25; i++)227 members.Add(new NBi.Core.Analysis.Member.Member(string.Format("[Hierarchy].[member {0}]", i), string.Format("member {0}", i), i, 0));228229 var containConstraint = new NBi.NUnit.Member.ContainConstraint("Searched member");230231 //Call the method to test232 containConstraint.Matches(members);233 containConstraint.WriteActualValueTo(writer);234235 //Test conclusion 236 var shortList = members.Take(10);237 mockWriter.Verify(wr => wr.WriteActualValue(shortList));238 mockWriter.Verify(wr => wr.WriteActualValue(It.Is<string>(str => str.Contains("15") && str.Contains("other"))));239 }240241 [Test]242 public void Matches_TwoCaptionsBothContainedInMembers_Validated()243 {244 //Buiding object used during test245 var members = new MemberResult();246 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));247 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));248249 var containConstraint = new NBi.NUnit.Member.ContainConstraint(new string[] { "First member", "Second member" });250251 //Call the method to test252 var res = containConstraint.Matches(members);253254 //Test conclusion 255 Assert.That(res, Is.True);256 }257258 [Test]259 public void Matches_TwoCaptionsOneOfThemIsNotContainedInMembers_Failure()260 {261 //Buiding object used during test262 var members = new MemberResult();263 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));264 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));265266 var containConstraint = new NBi.NUnit.Member.ContainConstraint(new string[] { "Third member", "Second member" });267268 //Call the method to test269 var res = containConstraint.Matches(members);270271 //Test conclusion 272 Assert.That(res, Is.False);273 }274275 276 }277} ...

Full Screen

Full Screen

OrderedConstraint.cs

Source:OrderedConstraint.cs Github

copy

Full Screen

1using System;2using System.Collections;3using System.Collections.Generic;4using NBi.Core.Analysis.Member;5using NBi.Core.Analysis.Request;6using NUnit.Framework.Constraints;7using NUnitCtr = NUnit.Framework.Constraints;89namespace NBi.NUnit.Member10{11 public class OrderedConstraint : AbstractMembersConstraint12 {13 private bool reversed;14 private IList<Object> specific;1516 /// <summary>17 /// Construct a CollectionContainsConstraint specific for Members18 /// </summary>19 /// <param name="expected"></param>20 public OrderedConstraint()21 : base()22 {23 Comparer = new AlphabeticalComparer();24 }2526 #region Modifiers27 /// <summary>28 /// Flag the constraint to ignore case and return self.29 /// </summary>30 public OrderedConstraint Descending31 {32 get33 {34 reversed = true;35 return this;36 }37 }38 39 /// <summary>40 /// Flag the constraint to use StringComparaison.41 /// </summary>42 public OrderedConstraint Alphabetical43 {44 get45 {46 Comparer = new AlphabeticalComparer();47 return this;48 }49 }5051 /// <summary>52 /// Flag the constraint to use DateTimeComparaison.53 /// </summary>54 public OrderedConstraint Chronological55 {56 get57 {58 Comparer = new ChronologicalComparer();59 return this;60 }61 }6263 /// <summary>64 /// Flag the constraint to use DecimalComparaison.65 /// </summary>66 public OrderedConstraint Numerical67 {68 get69 {70 Comparer = new NumericalComparer();71 return this;72 }73 }7475 /// <summary>76 /// Flag the constraint to use DecimalComparaison.77 /// </summary>78 public OrderedConstraint Specific(IList<Object> definition)79 {80 specific = definition;81 Comparer = null;82 return this;83 }8485 8687 protected override NUnitCtr.Constraint BuildInternalConstraint()88 {89 var ctr = new CollectionOrderedConstraint();90 if (this.reversed)91 ctr = ctr.Descending;92 if (Comparer != null) //Should only happens if specific is called93 ctr = ctr.Using(Comparer);94 return ctr;95 }9697 #endregion9899 protected override bool DoMatch(NUnitCtr.Constraint ctr)100 {101 if (specific == null)102 return ctr.Matches(actual);103 else104 return SpecificMatches(actual);105 }106107 protected bool SpecificMatches(object actual)108 { 109 int index=0;110 111 foreach (var item in (IEnumerable<Object>)actual)112 {113 var itemComparable = item is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)item).Caption : item;114115 int i = specific.IndexOf(itemComparable);116117 if (i > -1) //found118 {119 if (i < index)120 return false;121 else122 index = i;123 }124 }125126 return true;127 }128129 /// <summary>130 /// Write the constraint description to a MessageWriter131 /// </summary>132 /// <param name="writer">The writer on which the description is displayed</param>133 public override void WriteDescriptionTo(NUnitCtr.MessageWriter writer)134 {135136 writer.WritePredicate(string.Format("On perspective \"{0}\", the {1} of \"{2}\" are ordered {3}{4}"137 , Request.Perspective138 , Request.Function.ToLower()139 , Request.Path140 , Comparer == null ? "specifically" : ((IComparerWithLabel)Comparer).Label141 , reversed ? "(descending)" : string.Empty));142 }143144 protected interface IComparerWithLabel : IComparer145 {146 string Label { get; }147 }148149 protected class AlphabeticalComparer : IComparerWithLabel150 {151 private readonly IComparer internalComparer;152 153 public AlphabeticalComparer()154 {155 internalComparer = StringComparer.InvariantCultureIgnoreCase;156 }157158 public string Label159 {160 get161 {162 return "alphabetically";163 }164 }165166 int IComparer.Compare(Object x, Object y)167 {168 x = x is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)x).Caption : x;169 y = y is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)y).Caption : y;170171 return internalComparer.Compare(x, y);172 }173 }174175 protected class ChronologicalComparer : IComparerWithLabel176 {177 public ChronologicalComparer()178 {179 }180181 public string Label182 {183 get184 {185 return "chronologically";186 }187 }188 189 int IComparer.Compare(Object x, Object y)190 {191 x = x is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)x).Caption : x;192 y = y is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)y).Caption : y;193 194 if (x is DateTime && y is DateTime)195 return DateTime.Compare((DateTime)x,(DateTime)y);196 if (x is DateTime && y is String)197 {198 DateTime newY;199 if (DateTime.TryParse((string)y, out newY))200 return DateTime.Compare((DateTime)x, newY);201 else202 return 0;203 //throw new ArgumentException(string.Format("'{0}' cannot be converted to DateTime", y));204 }205 if (x is String && y is DateTime)206 {207 DateTime newX;208 if (DateTime.TryParse((string)x, out newX))209 return DateTime.Compare(newX, (DateTime)y);210 else211 return 0;212 //throw new ArgumentException(string.Format("'{0}' cannot be converted to DateTime", x));213 }214 if (x is String && y is String)215 {216 DateTime newX, newY;217 if (DateTime.TryParse((string)x, out newX) && DateTime.TryParse((string)y, out newY))218 return DateTime.Compare(newX, newY);219 else220 return 0;221 //throw new ArgumentException(string.Format("'{0}' of type '{1}' or '{2}' of type '{3}' cannot be converted to DateTime", x, x.GetType().Name, y, y.GetType().Name));222 }223 224225 throw new ArgumentException(string.Format("'{0}' or '{1}' cannot be compared chronologically", x.GetType().Name, y.GetType().Name));226 }227 }228229 protected class NumericalComparer : IComparerWithLabel230 {231 public NumericalComparer()232 {233 }234235 public string Label236 {237 get238 {239 return "numerically";240 }241 }242243 int IComparer.Compare(Object x, Object y)244 {245 x = x is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)x).Caption : x;246 y = y is NBi.Core.Analysis.Member.Member ? ((NBi.Core.Analysis.Member.Member)y).Caption : y;247248 Decimal newX, newY;249 if (Decimal.TryParse(x.ToString(), out newX) && Decimal.TryParse(y.ToString(), out newY))250 return Decimal.Compare(newX, newY);251 else252 return 0;253 //throw new ArgumentException(string.Format("'{0}' of type '{1}' or '{2}' of type '{3}' cannot be converted to Decimal", x, x.GetType().Name, y, y.GetType().Name));254 }255 }256 257 }258} ...

Full Screen

Full Screen

EquivalentToConstraintTest.cs

Source:EquivalentToConstraintTest.cs Github

copy

Full Screen

1using System.Collections.Generic;2using Moq;3using NBi.Core.Analysis.Member;4using NBi.Core.Analysis.Metadata;5using NBi.Core.Analysis.Metadata.Adomd;6using NBi.Core.Analysis.Request;7using NBi.NUnit.Member;8using NUnit.Framework;910namespace NBi.Testing.Unit.NUnit.Member11{12 [TestFixture]13 public class EquivalentToConstraintTest14 {15 [Test]16 public void WriteTo_FailingAssertionForListOfLevels_TextContainsFewKeyInfo()17 {18 var exp = new string[] { "Expected member 1", "Expected member 2" };19 var cmd = new DiscoveryRequestFactory().Build(20 "connectionString",21 "member-caption",22 "perspective-name",23 "dimension-caption", "hierarchy-caption", null);242526 var memberStub = new Mock<NBi.Core.Analysis.Member.Member>();27 var member1 = memberStub.Object;28 var member2 = memberStub.Object;29 var members = new MemberResult();30 members.Add(member1);31 members.Add(member2);3233 var meMock = new Mock<MembersAdomdEngine>();34 meMock.Setup(engine => engine.GetMembers(cmd))35 .Returns(members);36 var me = meMock.Object;3738 var equivalentConstraint = new EquivalentToConstraint(exp) { MembersEngine = me };3940 //Method under test41 string assertionText = null;42 try43 {44 Assert.That(cmd, equivalentConstraint);45 }46 catch (AssertionException ex)47 {48 assertionText = ex.Message;49 }5051 //Test conclusion 52 Assert.That(assertionText, Is.StringContaining("perspective-name").And53 .StringContaining("dimension-caption").And54 .StringContaining("hierarchy-caption").And55 .StringContaining("equivalent to").And56 .StringContaining("Expected member 1").And57 .StringContaining("Expected member 2"));58 }5960 [Test]61 public void Matches_OneCaptionContainedInMembers_Validated()62 {63 //Buiding object used during test64 var members = new MemberResult();65 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));66 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));6768 var equivalentConstraint = new NBi.NUnit.Member.EquivalentToConstraint(new List<string>() { "First member", "Second member" });6970 //Call the method to test71 var res = equivalentConstraint.Matches(members);7273 //Test conclusion 74 Assert.That(res, Is.True);75 }7677 [Test]78 public void Matches_OneCaptionContainedInMembersOneMore_Failure()79 {80 //Buiding object used during test81 var members = new MemberResult();82 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));83 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Second member]", "Second member", 2, 0));84 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[Third member]", "Third member", 3, 0));8586 var equivalentConstraint = new NBi.NUnit.Member.EquivalentToConstraint(new List<string>() { "First member", "Second member" });8788 //Call the method to test89 var res = equivalentConstraint.Matches(members);9091 //Test conclusion 92 Assert.That(res, Is.False);93 }9495 [Test]96 public void Matches_OneCaptionContainedInMembersOneLess_Failure()97 {98 //Buiding object used during test99 var members = new MemberResult();100 members.Add(new NBi.Core.Analysis.Member.Member("[Hierarchy].[First member]", "First member", 1, 0));101102 var equivalentConstraint = new NBi.NUnit.Member.EquivalentToConstraint(new List<string>() { "First member", "Second member" });103104 //Call the method to test105 var res = equivalentConstraint.Matches(members);106107 //Test conclusion 108 Assert.That(res, Is.False);109 }110 111112 113 }114} ...

Full Screen

Full Screen

Member

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Analysis.Member;2using NBi.Core.Analysis.Member;3using NBi.Core.Analysis.Member;4using NBi.Core.Analysis.Member;5using NBi.Core.Analysis.Member;6using NBi.Core.Analysis.Member;7using NBi.Core.Analysis.Member;8using NBi.Core.Analysis.Member;9using NBi.Core.Analysis.Member;10using NBi.Core.Analysis.Member;11using NBi.Core.Analysis.Member;12using NBi.Core.Analysis.Member;13using NBi.Core.Analysis.Member;14using NBi.Core.Analysis.Member;15using NBi.Core.Analysis.Member;16using NBi.Core.Analysis.Member;17using NBi.Core.Analysis.Member;18using NBi.Core.Analysis.Member;19using NBi.Core.Analysis.Member;20using NBi.Core.Analysis.Member;21using NBi.Core.Analysis.Member;

Full Screen

Full Screen

Member

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Analysis.Member;2using NBi.Core.Analysis.Member.Adomd;3using NBi.Core.Analysis.Member.Olap;4using NBi.Core.Analysis.Member.Rs;5using NBi.Core.Analysis.Member.Ssas;6using NBi.Core.Analysis.Member.Ssrs;7using NBi.Core.Analysis.Member.Ssrs2008;8using NBi.Core.Analysis.Member.Ssrs2010;9using NBi.Core.Analysis.Member.Ssrs2012;10using NBi.Core.Analysis.Member.Ssrs2014;11using NBi.Core.Analysis.Member.Ssrs2016;12using NBi.Core.Analysis.Member.Ssrs2017;13using NBi.Core.Analysis.Member.Ssrs2019;14using NBi.Core.Analysis.Member.Ssrs2021;15using NBi.Core.Analysis.Member.Ssrs2022;16using NBi.Core.Analysis.Member.Ssrs2024;17using NBi.Core.Analysis.Member.Ssrs2026;18using NBi.Core.Analysis.Member.Ssrs2027;

Full Screen

Full Screen

Member

Using AI Code Generation

copy

Full Screen

1var member = new Member("Dim1", "Dim2", "Dim3");2member.Caption = "Dim1Dim2Dim3";3var member = new Member("Dim1", "Dim2", "Dim3");4member.Caption = "Dim1Dim2Dim3";5var member = new Member("Dim1", "Dim2", "Dim3");6member.Caption = "Dim1Dim2Dim3";7var member = new Member("Dim1", "Dim2", "Dim3");8member.Caption = "Dim1Dim2Dim3";9var member = new Member("Dim1", "Dim2", "Dim3");10member.Caption = "Dim1Dim2Dim3";11var member = new Member("Dim1", "Dim2", "Dim3");12member.Caption = "Dim1Dim2Dim3";13var member = new Member("Dim1", "Dim2", "Dim3");14member.Caption = "Dim1Dim2Dim3";15var member = new Member("Dim1", "Dim2", "Dim3");16member.Caption = "Dim1Dim2Dim3";17var member = new Member("Dim1", "Dim2", "Dim3");18member.Caption = "Dim1Dim2Dim3";19var member = new Member("Dim1", "Dim2", "Dim3");20member.Caption = "Dim1Dim2Dim3";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in Member

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful