public void GetSystemUnderTest_BuildWithHierarchy_CorrectCallToDiscoverFactory() { var sutXml = new MembersXml(); sutXml.ChildrenOf = "memberCaption"; var item = new HierarchyXml(); sutXml.Item = item; item.ConnectionString = "connectionString"; item.Perspective = "perspective"; item.Dimension = "dimension"; item.Caption = "hierarchy"; var ctrXml = new OrderedXml(); var discoFactoMockFactory = new Mock<DiscoveryRequestFactory>(); discoFactoMockFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoMock = discoFactoMockFactory.Object; var builder = new MembersOrderedBuilder(discoFactoMock); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.InstanceOf<MembersDiscoveryRequest>()); discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString", "memberCaption", It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), "perspective", "dimension", "hierarchy", null)); }
public void GetConstraint_BuildWithPredefinedItems_CorrectConstraint() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; var ctrXml = new EquivalentToXml(); ctrXml.PredefinedItems = new PredefinedItemsXml() { Type=PredefinedMembers.DaysOfWeek, Language = "en" }; var discoFactoStubFactory = new Mock<DiscoveryRequestFactory>(); discoFactoStubFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoStub = discoFactoStubFactory.Object; var builder = new MembersEquivalentToBuilder(discoFactoStub); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<EquivalentToConstraint>()); }
public void GetConstraint_Build_CorrectConstraint() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; var ctrXml = new OrderedXml(); var discoFactoStubFactory = new Mock<DiscoveryRequestFactory>(); discoFactoStubFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoStub = discoFactoStubFactory.Object; var builder = new MembersOrderedBuilder(discoFactoStub); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<OrderedConstraint>()); }
protected override void BaseSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { if (!(sutXml is MembersXml)) throw new ArgumentException("Constraint must be a 'MembesrXml'"); SystemUnderTestXml = (MembersXml)sutXml; }
public void GetSystemUnderTest_BuildWithDimension_Failure() { var sutXml = new MembersXml(); sutXml.ChildrenOf = "memberCaption"; var item = new DimensionXml(); sutXml.Item = item; item.ConnectionString = "connectionString"; item.Perspective = "perspective"; item.Caption = "dimension"; var ctrXml = new ContainXml(); var discoFactoStubFactory = new Mock<DiscoveryRequestFactory>(); discoFactoStubFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoMock = discoFactoStubFactory.Object; var builder = new MembersContainBuilder(discoFactoMock); builder.Setup(sutXml, ctrXml); Assert.Throws<ArgumentOutOfRangeException>(delegate { builder.Build(); }); }
protected MembersDiscoveryRequest InstantiateMembersDiscovery(MembersXml membersXml) { string perspective = null, dimension = null, hierarchy = null, level = null, set=null; MembersDiscoveryRequest disco = null; if (membersXml.Item == null) throw new ArgumentNullException(); if (!(membersXml.Item is HierarchyXml || membersXml.Item is LevelXml || membersXml.Item is SetXml)) { throw new ArgumentOutOfRangeException(); } if (membersXml.Item is HierarchyXml) { perspective = ((HierarchyXml)membersXml.Item).Perspective; dimension = ((HierarchyXml)membersXml.Item).Dimension; hierarchy = membersXml.Item.Caption; } if (membersXml.Item is LevelXml) { perspective = ((LevelXml)membersXml.Item).Perspective; dimension = ((LevelXml)membersXml.Item).Dimension; hierarchy = ((LevelXml)membersXml.Item).Hierarchy; level = membersXml.Item.Caption; } if (membersXml.Item is HierarchyXml || membersXml.Item is LevelXml) { disco = discoveryFactory.Build( membersXml.Item.GetConnectionString(), membersXml.ChildrenOf, membersXml.Exclude.Items, BuildPatterns(membersXml.Exclude.Patterns), perspective, dimension, hierarchy, level); } if (membersXml.Item is SetXml) { perspective = ((SetXml)membersXml.Item).Perspective; set = membersXml.Item.Caption; disco = discoveryFactory.Build( membersXml.Item.GetConnectionString(), membersXml.Exclude.Items, BuildPatterns(membersXml.Exclude.Patterns), perspective, set); } if (disco == null) throw new ArgumentException(); return disco; }
public void Instantiate_MembersContains_ArgumentException() { var sutXml = new MembersXml(); var ctrXml = new ContainXml(); var builderMockFactory = new Mock<ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.ContainConstraint("expected")); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(MembersXml), typeof(ContainXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void Instantiate_MembersMatchPattern_TestCase() { var sutXml = new MembersXml(); var ctrXml = new MatchPatternXml(); var builderMockFactory = new Mock<ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.MatchPatternConstraint()); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(MembersXml), typeof(MatchPatternXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void GetConstraint_BuildWithQuery_CorrectConstraint() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; var ctrXml = new EquivalentToXml(); ctrXml.Query = new QueryXml(); ctrXml.Query.ConnectionString = "Data Source=mhknbn2kdz.database.windows.net;Initial Catalog=AdventureWorks2012;User Id=sqlfamily;password=sqlf@m1ly"; ctrXml.Query.InlineQuery = "select * from one-column-table"; var discoFactoStubFactory = new Mock<DiscoveryRequestFactory>(); discoFactoStubFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoStub = discoFactoStubFactory.Object; var builder = new MembersEquivalentToBuilder(discoFactoStub); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<EquivalentToConstraint>()); }
protected object InstantiateSystemUnderTest(MembersXml sutXml) { try { return InstantiateMembersDiscovery(sutXml); } catch (ArgumentOutOfRangeException) { throw new ArgumentOutOfRangeException("sutXml", sutXml, "The system-under-test for members must be a hierarchy or a level or a set"); } }
public void GetConstraint_BuildWithRange_CorrectConstraint() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; var ctrXml = new EquivalentToXml(); ctrXml.Range = new IntegerRangeXml() { Start = 1, End = 10, Step = 2 }; var discoFactoStubFactory = new Mock<DiscoveryRequestFactory>(); discoFactoStubFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoStub = discoFactoStubFactory.Object; var builder = new MembersEquivalentToBuilder(discoFactoStub); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<EquivalentToConstraint>()); }
public void Instantiate_MembersOrdered_ArgumentException() { var sutXml = new MembersXml(); var ctrXml = new OrderedXml(); var builderMockFactory = new Mock<ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new OrderedConstraint()); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(MembersXml), typeof(OrderedXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void Instantiate_MembersSyntacticallyCorrect_ArgumentException() { var sutXml = new MembersXml(); var ctrXml = new SyntacticallyCorrectXml(); var testCaseFactory = new TestCaseFactory(); Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); }); }
public void Instantiate_MembersFasterThan_ArgumentException() { var sutXml = new MembersXml(); var ctrXml = new FasterThanXml(); var testCaseFactory = new TestCaseFactory(); Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); }); }
public void GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; item.Perspective = "perspective"; item.Dimension = "dimension"; item.Caption = "hierarchy"; var defXml = new DefaultXml(); defXml.ConnectionString = "connectionString-default"; sutXml.Default = defXml; var ctrXml = new OrderedXml(); var discoFactoMockFactory = new Mock<DiscoveryRequestFactory>(); discoFactoMockFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoMock = discoFactoMockFactory.Object; var builder = new MembersOrderedBuilder(discoFactoMock); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.InstanceOf<MembersDiscoveryRequest>()); discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString-default", It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null)); }
public void GetSystemUnderTest_ConnectionStringInReference_CorrectlyInitialized() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; item.Perspective = "perspective"; item.Dimension = "dimension"; item.Caption = "hierarchy"; item.ConnectionString = "@ref-connStr"; var settingsXml = new SettingsXml(); settingsXml.References.Add(new ReferenceXml() {Name="ref-connStr", ConnectionString="connectionString-ref"}); sutXml.Settings = settingsXml; var ctrXml = new CountXml(); var discoFactoMockFactory = new Mock<DiscoveryRequestFactory>(); discoFactoMockFactory.Setup(dfs => dfs.Build( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new MembersDiscoveryRequest()); var discoFactoMock = discoFactoMockFactory.Object; var builder = new MembersCountBuilder(discoFactoMock); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.InstanceOf<MembersDiscoveryRequest>()); discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString-ref", It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null)); }
public void IsHandling_MembersSyntacticallyCorrect_False() { var sutXml = new MembersXml(); var ctrXml = new SyntacticallyCorrectXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }
public void IsHandling_MembersOrdered_True() { var sutXml = new MembersXml(); var ctrXml = new OrderedXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.True); }
public void IsHandling_MembersFasterThan_False() { var sutXml = new MembersXml(); var ctrXml = new FasterThanXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }