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 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", "memberCaption", It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), "perspective", "dimension", "hierarchy", null)); }
protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { if (!(ctrXml is CountXml)) throw new ArgumentException("Constraint must be a 'CountXml'"); ConstraintXml = (CountXml)ctrXml; }
public void GetConstraint_Build_CorrectConstraint() { var sutXml = new MembersXml(); var item = new HierarchyXml(); sutXml.Item = item; var ctrXml = new CountXml(); 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 MembersCountBuilder(discoFactoStub); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<CountConstraint>()); }
public void Serialize_OnlyExactlySpecified_MoreThanLessThanNotSet() { var count = new CountXml(); count.Exactly = 10; var manager = new XmlManager(); var xml = manager.XmlSerializeFrom<CountXml>(count); Assert.That(xml, Is.StringContaining("exactly")); Assert.That(xml, Is.Not.StringContaining("more-than")); Assert.That(xml, Is.Not.StringContaining("less-than")); }
protected global::NUnit.Framework.Constraints.Constraint InstantiateConstraint(CountXml ctrXml) { var ctr = new NBi.NUnit.Member.CountConstraint(); if (ctrXml.Specification.IsExactlySpecified) ctr = ctr.Exactly(ctrXml.Exactly); if (ctrXml.Specification.IsMoreThanSpecified) ctr = ctr.MoreThan(ctrXml.MoreThan); if (ctrXml.Specification.IsLessThanSpecified) ctr = ctr.LessThan(ctrXml.LessThan); return ctr; }
public void Instantiate_MembersCount_ArgumentException() { var sutXml = new MembersXml(); var ctrXml = new CountXml(); 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 CountConstraint()); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(MembersXml), typeof(CountXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void IsHandling_StructureCount_True() { var sutXml = new StructureXml(); var ctrXml = new CountXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }
public void IsHandling_QueryCount_False() { var sutXml = new ExecutionXml(); var ctrXml = new CountXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }
public void IsHandling_MembersCount_True() { var sutXml = new MembersXml(); var ctrXml = new CountXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.True); }
public void Instantiate_StructureCount_ArgumentException() { var sutXml = new StructureXml(); var ctrXml = new CountXml(); var testCaseFactory = new TestCaseFactory(); Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); }); }
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)); }