protected NBiConstraint InstantiateConstraint(IsXml ctrXml, DataTypeXml sutXml) { var expected = ctrXml.Value; var ctr = new IsConstraint(expected); return ctr; }
protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { if (!(ctrXml is IsXml)) throw new ArgumentException("Constraint must be a 'IsXml'"); if (!(sutXml is DataTypeXml)) throw new ArgumentException("System-under-test must be a 'DataTypeXml'"); SystemUnderTestXml = (DataTypeXml)sutXml; ConstraintXml = (IsXml)ctrXml; }
public void Instantiate_DataTypeIs_TestCase() { var sutXml = new DataTypeXml(); var ctrXml = new IsXml(); 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 RelationalCommand(new SqlCommand(), null, null)); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new IsConstraint("x")); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(DataTypeXml), typeof(IsXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void Serialize_IsXml_NoDefaultAndSettings() { var isXml = new IsXml(); isXml.Value = "decimal(10,2)"; var testXml = new TestXml(); testXml.Constraints.Add(isXml); var serializer = new XmlSerializer(typeof(TestXml)); var stream = new MemoryStream(); var writer = new StreamWriter(stream, Encoding.UTF8); serializer.Serialize(writer, testXml); var content = Encoding.UTF8.GetString(stream.ToArray()); writer.Close(); stream.Close(); Debug.WriteLine(content); Assert.That(content, Is.StringContaining("<is")); Assert.That(content, Is.StringContaining(">decimal(10,2)<")); Assert.That(content, Is.Not.StringContaining("efault")); Assert.That(content, Is.Not.StringContaining("eference")); }
public void IsHandling_DataTypeIs_True() { var sutXml = new DataTypeXml(); var ctrXml = new IsXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.True); }