public void GetConstraint_RowCountFiltered_CorrectConstraint() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty); ctrXml.Equal = new EqualXml(); ctrXml.Filter = new FilterXml(); ctrXml.Filter.Variables.Add(new VariableXml()); ctrXml.Equal.Value = "50"; var builder = new ExecutionRowCountBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <RowCountFilterConstraint>()); var rowCount = ctr as RowCountFilterConstraint; Assert.That(rowCount.Child, Is.InstanceOf <NUnitCtr.EqualConstraint>()); }
public void GetConstraint_BuildWithResultSet_CorrectConstraint() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty) { MoreThan = new MoreThanXml() { Value = "100" } }; var builder = new ResultSetRowCountBuilder(); builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator()); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <RowCountConstraint>()); var rowCount = ctr as RowCountConstraint; Assert.That(rowCount.Differed.Resolve(), Is.InstanceOf <NUnitCtr.GreaterThanConstraint>()); }
public void GetSystemUnderTest_ExecutionXml_IResultSetService() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty) { MoreThan = new MoreThanXml() { Value = "10" } }; var builder = new ResultSetRowCountBuilder(); builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator()); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.Not.Null); Assert.That(sut, Is.InstanceOf <IResultSetService>()); }
public void GetConstraint_RowCountFiltered_CorrectConstraint() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty); ctrXml.Equal = new EqualXml(); ctrXml.Equal.Value = "50"; ctrXml.Filter = new FilterXml(); ctrXml.Filter.InternalAliases.Add(new AliasXml()); ctrXml.Filter.Predication = new PredicationXml() { Predicate = new NullXml(), Operand = "myColumn" }; var builder = new ResultSetRowCountBuilder(); builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator()); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <RowCountFilterConstraint>()); var rowCount = ctr as RowCountFilterConstraint; Assert.That(rowCount.Differed.Resolve(), Is.InstanceOf <NUnitCtr.EqualConstraint>()); }
public void Serialize_WithLessThanAndFilter_LessThanBeforeFilter() { var rowCountXml = new RowCountXml() { Filter = new FilterXml(), LessThan = new LessThanXml() }; var serializer = new XmlSerializer(typeof(RowCountXml)); var stream = new MemoryStream(); var writer = new StreamWriter(stream, Encoding.UTF8); serializer.Serialize(writer, rowCountXml); var content = Encoding.UTF8.GetString(stream.ToArray()); writer.Close(); stream.Close(); Debug.WriteLine(content); Assert.That(content, Is.StringContaining("<filter")); Assert.That(content, Is.StringContaining("<less-than")); Assert.That(content, Is.StringMatching(@".*<filter.*/>[\r\n]*.*<less-than.*/>.*")); }
public void GetConstraint_PercentageForRowCount_CorrectConstraint() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty); ctrXml.Equal = new EqualXml(); ctrXml.Equal.Value = "50.4%"; ctrXml.Filter = new FilterXml(); ctrXml.Filter.InternalAliases.Add(new AliasXml()); ctrXml.Filter.Predicate = new PredicateXml() { Null = new NullXml(), Name = "myColumn" }; var builder = new ExecutionRowCountBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <RowCountFilterPercentageConstraint>()); var rowCount = ctr as RowCountFilterPercentageConstraint; Assert.That(rowCount.Child, Is.InstanceOf <NUnitCtr.EqualConstraint>()); }
protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { if (!(ctrXml is RowCountXml)) { throw new ArgumentException("Constraint must be a 'RowCountXml'"); } ConstraintXml = (RowCountXml)ctrXml; }
public void IsHandling_QueryRowCount_True() { var sutXml = new ExecutionXml(); var ctrXml = new RowCountXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.True); }
public void GetConstraint_PercentageForRowCount_CorrectConstraint() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryXml>(); itemXmlStubFactory.Setup(i => i.InlineQuery).Returns("query"); itemXmlStubFactory.Setup(i => i.Settings).Returns(SettingsXml.Empty); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty) { Equal = new EqualXml() { Reference = "50.4%" }, Filter = new FilterXml() { InternalAliases = new List <AliasXml>() { new AliasXml() }, Predication = new SinglePredicationXml() { Predicate = new NullXml(), Operand = new ColumnNameIdentifier("myColumn") } } }; var builder = new ResultSetRowCountBuilder(); builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator()); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <RowCountFilterPercentageConstraint>()); var rowCount = ctr as RowCountFilterPercentageConstraint; Assert.That(rowCount.Differed.Resolve(), Is.InstanceOf <NUnitCtr.EqualConstraint>()); }
public void GetConstraint_NonIntegerValueForRowCount_ThrowException() { var sutXmlStubFactory = new Mock <Systems.ExecutionXml>(); var itemXmlStubFactory = new Mock <QueryableXml>(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; var ctrXml = new RowCountXml(SettingsXml.Empty); ctrXml.MoreThan = new MoreThanXml(); ctrXml.MoreThan.Value = "Something"; var builder = new ExecutionRowCountBuilder(); builder.Setup(sutXml, ctrXml); Assert.Throws <ArgumentException>(delegate { builder.Build(); }); }
public void Instantiate_QueryRowCount_TestCase() { var sutXml = new ExecutionXml(); var ctrXml = new RowCountXml(); var builderMockFactory = new Mock <ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default, It.IsAny <Dictionary <string, ITestVariable> >())); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new RowCountConstraint(null)); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(ExecutionXml), typeof(RowCountXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void GetSystemUnderTest_ResultSetSystemXml_IResultSetService() { var sutXmlStub = new Mock <Systems.ResultSetSystemXml>(); sutXmlStub.Setup(s => s.File.Path).Returns("myFile.csv"); var sutXml = sutXmlStub.Object; var ctrXml = new RowCountXml(SettingsXml.Empty) { MoreThan = new MoreThanXml() { Value = "10" } }; var builder = new ResultSetRowCountBuilder(); builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator()); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.Not.Null); Assert.That(sut, Is.InstanceOf <IResultSetService>()); }
public void Serialize_WithLessThanAndFilter_OnlyAliasNoVariable() { var rowCountXml = new RowCountXml() { Filter = new FilterXml() { InternalAliases = new List <AliasXml>() { new AliasXml() { Column = 1, Name = "Col1" }, new AliasXml() { Column = 0, Name = "Col2" } } }, LessThan = new LessThanXml() }; var serializer = new XmlSerializer(typeof(RowCountXml)); var stream = new MemoryStream(); var writer = new StreamWriter(stream, Encoding.UTF8); serializer.Serialize(writer, rowCountXml); var content = Encoding.UTF8.GetString(stream.ToArray()); writer.Close(); stream.Close(); Debug.WriteLine(content); Assert.That(content, Is.StringContaining("<alias")); Assert.That(content, Is.Not.StringContaining("<variable")); }