Best NBi code snippet using NBi.NUnit.TestCaseFactory.Instantiate
TestCaseFactoryTest.cs
Source:TestCaseFactoryTest.cs
...41 Assert.That(actual, Is.True);42 }43 44 [Test]45 public void Instantiate_QuerySyntacticallyCorrect_TestCase()46 {47 var sutXml = new ExecutionXml();48 var ctrXml = new SyntacticallyCorrectXml();49 var builderMockFactory = new Mock<ITestCaseBuilder>();50 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));51 builderMockFactory.Setup(b => b.Build());52 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());53 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new SyntacticallyCorrectConstraint());54 var builder = builderMockFactory.Object;55 var testCaseFactory = new TestCaseFactory();56 testCaseFactory.Register(typeof(ExecutionXml), typeof(SyntacticallyCorrectXml), builder);57 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);58 Assert.That(tc, Is.Not.Null);59 builderMockFactory.VerifyAll();60 }61 [Test]62 public void IsHandling_MembersSyntacticallyCorrect_False()63 {64 var sutXml = new MembersXml();65 var ctrXml = new SyntacticallyCorrectXml();66 var testCaseFactory = new TestCaseFactory();67 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());68 Assert.That(actual, Is.False);69 }70 [Test]71 public void Instantiate_MembersSyntacticallyCorrect_ArgumentException()72 {73 var sutXml = new MembersXml();74 var ctrXml = new SyntacticallyCorrectXml();75 var testCaseFactory = new TestCaseFactory();76 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });77 }78 [Test]79 public void IsHandling_StructureSyntacticallyCorrect_False()80 {81 var sutXml = new StructureXml();82 var ctrXml = new SyntacticallyCorrectXml();83 var testCaseFactory = new TestCaseFactory();84 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());85 Assert.That(actual, Is.False);86 }87 [Test]88 public void Instantiate_StructureSyntacticallyCorrect_ArgumentException()89 {90 var sutXml = new StructureXml();91 var ctrXml = new SyntacticallyCorrectXml();92 var testCaseFactory = new TestCaseFactory();93 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });94 }95 [Test]96 public void IsHandling_QueryFasterThan_True()97 {98 var sutXml = new ExecutionXml();99 var ctrXml = new FasterThanXml();100 var testCaseFactory = new TestCaseFactory();101 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());102 Assert.That(actual, Is.True);103 }104 [Test]105 public void Instantiate_QueryFasterThan_TestCase()106 {107 var sutXml = new ExecutionXml();108 var ctrXml = new FasterThanXml();109 var builderMockFactory = new Mock<ITestCaseBuilder>();110 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));111 builderMockFactory.Setup(b => b.Build());112 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());113 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new FasterThanConstraint());114 var builder = builderMockFactory.Object;115 var testCaseFactory = new TestCaseFactory();116 testCaseFactory.Register(typeof(ExecutionXml), typeof(FasterThanXml), builder);117 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);118 Assert.That(tc, Is.Not.Null);119 builderMockFactory.VerifyAll();120 }121 [Test]122 public void IsHandling_MembersFasterThan_False()123 {124 var sutXml = new MembersXml();125 var ctrXml = new FasterThanXml();126 var testCaseFactory = new TestCaseFactory();127 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());128 Assert.That(actual, Is.False);129 }130 [Test]131 public void Instantiate_MembersFasterThan_ArgumentException()132 {133 var sutXml = new MembersXml();134 var ctrXml = new FasterThanXml();135 var testCaseFactory = new TestCaseFactory();136 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });137 }138 [Test]139 public void IsHandling_StructureFasterThan_False()140 {141 var sutXml = new StructureXml();142 var ctrXml = new FasterThanXml();143 var testCaseFactory = new TestCaseFactory();144 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());145 Assert.That(actual, Is.False);146 }147 [Test]148 public void Instantiate_StructureFasterThan_ArgumentException()149 {150 var sutXml = new StructureXml();151 var ctrXml = new FasterThanXml();152 var testCaseFactory = new TestCaseFactory();153 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });154 }155 [Test]156 public void IsHandling_QueryEqualTo_True()157 {158 var sutXml = new ExecutionXml();159 var ctrXml = new EqualToXml();160 var testCaseFactory = new TestCaseFactory();161 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());162 Assert.That(actual, Is.True);163 }164 [Test]165 public void IsHandling_QuerySupersetOf_True()166 {167 var sutXml = new ExecutionXml();168 var ctrXml = new SupersetOfXml();169 var testCaseFactory = new TestCaseFactory();170 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());171 Assert.That(actual, Is.True);172 }173 [Test]174 public void Instantiate_QueryEqualTo_TestCase()175 {176 var sutXml = new ExecutionXml();177 var ctrXml = new EqualToXml();178 var builderMockFactory = new Mock<ITestCaseBuilder>();179 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));180 builderMockFactory.Setup(b => b.Build());181 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());182 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new EqualToConstraint(null));183 var builder = builderMockFactory.Object;184 var testCaseFactory = new TestCaseFactory();185 testCaseFactory.Register(typeof(ExecutionXml), typeof(EqualToXml), builder);186 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);187 Assert.That(tc, Is.Not.Null);188 builderMockFactory.VerifyAll();189 }190 [Test]191 public void IsHandling_MembersEqualTo_False()192 {193 var sutXml = new MembersXml();194 var ctrXml = new EqualToXml();195 var testCaseFactory = new TestCaseFactory();196 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());197 Assert.That(actual, Is.False);198 }199 [Test]200 public void Instantiate_MembersEqualTo_ArgumentException()201 {202 var sutXml = new MembersXml();203 var ctrXml = new EqualToXml();204 var testCaseFactory = new TestCaseFactory();205 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });206 }207 [Test]208 public void IsHandling_StructureEqualTo_False()209 {210 var sutXml = new StructureXml();211 var ctrXml = new EqualToXml();212 var testCaseFactory = new TestCaseFactory();213 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());214 Assert.That(actual, Is.False);215 }216 [Test]217 public void Instantiate_StructureEqualTo_ArgumentException()218 {219 var sutXml = new StructureXml();220 var ctrXml = new EqualToXml();221 var testCaseFactory = new TestCaseFactory();222 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });223 }224 [Test]225 public void IsHandling_QueryContains_False()226 {227 var sutXml = new ExecutionXml();228 var ctrXml = new ContainXml();229 var testCaseFactory = new TestCaseFactory();230 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());231 Assert.That(actual, Is.False);232 }233 [Test]234 public void Instantiate_QueryContains_ArgumentException()235 {236 var sutXml = new ExecutionXml();237 var ctrXml = new ContainXml();238 var testCaseFactory = new TestCaseFactory();239 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });240 }241 [Test]242 public void IsHandling_MembersContains_True()243 {244 var sutXml = new MembersXml();245 var ctrXml = new ContainXml();246 var testCaseFactory = new TestCaseFactory();247 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());248 Assert.That(actual, Is.True);249 }250 [Test]251 public void Instantiate_MembersContains_ArgumentException()252 {253 var sutXml = new MembersXml();254 var ctrXml = new ContainXml();255 var builderMockFactory = new Mock<ITestCaseBuilder>();256 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));257 builderMockFactory.Setup(b => b.Build());258 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());259 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.ContainConstraint("expected"));260 var builder = builderMockFactory.Object;261 var testCaseFactory = new TestCaseFactory();262 testCaseFactory.Register(typeof(MembersXml), typeof(ContainXml), builder);263 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);264 Assert.That(tc, Is.Not.Null);265 builderMockFactory.VerifyAll();266 }267 [Test]268 public void IsHandling_StructureContains_True()269 {270 var sutXml = new StructureXml();271 var ctrXml = new ContainXml();272 var testCaseFactory = new TestCaseFactory();273 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());274 Assert.That(actual, Is.True);275 }276 [Test]277 public void Instantiate_StructureContains_ArgumentException()278 {279 var sutXml = new StructureXml();280 var ctrXml = new ContainXml();281 var builderMockFactory = new Mock<ITestCaseBuilder>();282 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));283 builderMockFactory.Setup(b => b.Build());284 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());285 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Structure.ContainConstraint("expected"));286 var builder = builderMockFactory.Object;287 var testCaseFactory = new TestCaseFactory();288 testCaseFactory.Register(typeof(StructureXml), typeof(ContainXml), builder);289 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);290 Assert.That(tc, Is.Not.Null);291 builderMockFactory.VerifyAll();292 }293 [Test]294 public void IsHandling_QueryCount_False()295 {296 var sutXml = new ExecutionXml();297 var ctrXml = new CountXml();298 var testCaseFactory = new TestCaseFactory();299 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());300 Assert.That(actual, Is.False);301 }302 [Test]303 public void Instantiate_QueryCount_ArgumentException()304 {305 var sutXml = new ExecutionXml();306 var ctrXml = new CountXml();307 var testCaseFactory = new TestCaseFactory();308 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });309 }310 [Test]311 public void IsHandling_MembersCount_True()312 {313 var sutXml = new MembersXml();314 var ctrXml = new CountXml();315 var testCaseFactory = new TestCaseFactory();316 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());317 Assert.That(actual, Is.True);318 }319 [Test]320 public void Instantiate_MembersCount_ArgumentException()321 {322 var sutXml = new MembersXml();323 var ctrXml = new CountXml();324 var builderMockFactory = new Mock<ITestCaseBuilder>();325 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));326 builderMockFactory.Setup(b => b.Build());327 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());328 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new CountConstraint());329 var builder = builderMockFactory.Object;330 var testCaseFactory = new TestCaseFactory();331 testCaseFactory.Register(typeof(MembersXml), typeof(CountXml), builder);332 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);333 Assert.That(tc, Is.Not.Null);334 builderMockFactory.VerifyAll();335 }336 [Test]337 public void IsHandling_StructureCount_True()338 {339 var sutXml = new StructureXml();340 var ctrXml = new CountXml();341 var testCaseFactory = new TestCaseFactory();342 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());343 Assert.That(actual, Is.False);344 }345 [Test]346 public void Instantiate_StructureCount_ArgumentException()347 {348 var sutXml = new StructureXml();349 var ctrXml = new CountXml();350 var testCaseFactory = new TestCaseFactory();351 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });352 }353 [Test]354 public void IsHandling_QueryOrdered_False()355 {356 var sutXml = new ExecutionXml();357 var ctrXml = new OrderedXml();358 var testCaseFactory = new TestCaseFactory();359 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());360 Assert.That(actual, Is.False);361 }362 [Test]363 public void Instantiate_QueryOrdered_ArgumentException()364 {365 var sutXml = new ExecutionXml();366 var ctrXml = new OrderedXml();367 var testCaseFactory = new TestCaseFactory();368 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });369 }370 [Test]371 public void IsHandling_MembersOrdered_True()372 {373 var sutXml = new MembersXml();374 var ctrXml = new OrderedXml();375 var testCaseFactory = new TestCaseFactory();376 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());377 Assert.That(actual, Is.True);378 }379 [Test]380 public void Instantiate_MembersOrdered_ArgumentException()381 {382 var sutXml = new MembersXml();383 var ctrXml = new OrderedXml();384 var builderMockFactory = new Mock<ITestCaseBuilder>();385 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));386 builderMockFactory.Setup(b => b.Build());387 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());388 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new OrderedConstraint());389 var builder = builderMockFactory.Object;390 var testCaseFactory = new TestCaseFactory();391 testCaseFactory.Register(typeof(MembersXml), typeof(OrderedXml), builder);392 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);393 Assert.That(tc, Is.Not.Null);394 builderMockFactory.VerifyAll();395 }396 [Test]397 public void IsHandling_StructureOrdered_True()398 {399 var sutXml = new StructureXml();400 var ctrXml = new OrderedXml();401 var testCaseFactory = new TestCaseFactory();402 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());403 Assert.That(actual, Is.False);404 }405 [Test]406 public void Instantiate_StructureOrdered_ArgumentException()407 {408 var sutXml = new StructureXml();409 var ctrXml = new OrderedXml();410 var testCaseFactory = new TestCaseFactory();411 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });412 }413 [Test]414 public void IsHandling_QueryExists_False()415 {416 var sutXml = new ExecutionXml();417 var ctrXml = new ExistsXml();418 var testCaseFactory = new TestCaseFactory();419 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());420 Assert.That(actual, Is.False);421 }422 [Test]423 public void Instantiate_QueryExists_ArgumentException()424 {425 var sutXml = new ExecutionXml();426 var ctrXml = new ExistsXml();427 var testCaseFactory = new TestCaseFactory();428 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });429 }430 [Test]431 public void IsHandling_MembersExists_False()432 {433 var sutXml = new MembersXml();434 var ctrXml = new ExistsXml();435 var testCaseFactory = new TestCaseFactory();436 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());437 Assert.That(actual, Is.False);438 }439 [Test]440 public void Instantiate_MembersExists_ArgumentException()441 {442 var sutXml = new MembersXml();443 var ctrXml = new ExistsXml();444 var testCaseFactory = new TestCaseFactory();445 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });446 }447 [Test]448 public void IsHandling_StructureExists_True()449 {450 var sutXml = new StructureXml();451 var ctrXml = new ExistsXml();452 var testCaseFactory = new TestCaseFactory();453 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());454 Assert.That(actual, Is.True);455 }456 [Test]457 public void Instantiate_StructureExists_TestCase()458 {459 var sutXml = new StructureXml();460 var ctrXml = new ExistsXml();461 var builderMockFactory = new Mock<ITestCaseBuilder>();462 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));463 builderMockFactory.Setup(b => b.Build());464 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());465 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new ExistsConstraint("foo"));466 var builder = builderMockFactory.Object;467 var testCaseFactory = new TestCaseFactory();468 testCaseFactory.Register(typeof(StructureXml), typeof(ExistsXml), builder);469 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);470 Assert.That(tc, Is.Not.Null);471 builderMockFactory.VerifyAll();472 }473 [Test]474 public void IsHandling_MembersMatchPattern_True()475 {476 var sutXml = new MembersXml();477 var ctrXml = new MatchPatternXml();478 var testCaseFactory = new TestCaseFactory();479 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());480 Assert.That(actual, Is.True);481 }482 [Test]483 public void Instantiate_MembersMatchPattern_TestCase()484 {485 var sutXml = new MembersXml();486 var ctrXml = new MatchPatternXml();487 var builderMockFactory = new Mock<ITestCaseBuilder>();488 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));489 builderMockFactory.Setup(b => b.Build());490 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());491 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.MatchPatternConstraint());492 var builder = builderMockFactory.Object;493 var testCaseFactory = new TestCaseFactory();494 testCaseFactory.Register(typeof(MembersXml), typeof(MatchPatternXml), builder);495 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);496 Assert.That(tc, Is.Not.Null);497 builderMockFactory.VerifyAll();498 }499 [Test]500 public void IsHandling_ExecutionMatchPattern_True()501 {502 var sutXml = new ExecutionXml();503 var ctrXml = new MatchPatternXml();504 var testCaseFactory = new TestCaseFactory();505 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());506 Assert.That(actual, Is.True);507 }508 [Test]509 public void Instantiate_ExecutionMatchPattern_TestCase()510 {511 var sutXml = new ExecutionXml();512 var ctrXml = new MatchPatternXml();513 var builderMockFactory = new Mock<ITestCaseBuilder>();514 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));515 builderMockFactory.Setup(b => b.Build());516 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());517 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Query.MatchPatternConstraint());518 var builder = builderMockFactory.Object;519 var testCaseFactory = new TestCaseFactory();520 testCaseFactory.Register(typeof(ExecutionXml), typeof(MatchPatternXml), builder);521 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);522 Assert.That(tc, Is.Not.Null);523 builderMockFactory.VerifyAll();524 }525 [Test]526 public void IsHandling_QueryRowCount_True()527 {528 var sutXml = new ExecutionXml();529 var ctrXml = new RowCountXml();530 var testCaseFactory = new TestCaseFactory();531 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());532 Assert.That(actual, Is.True);533 }534 [Test]535 public void Instantiate_QueryRowCount_TestCase()536 {537 var sutXml = new ExecutionXml();538 var ctrXml = new RowCountXml();539 var builderMockFactory = new Mock<ITestCaseBuilder>();540 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));541 builderMockFactory.Setup(b => b.Build());542 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());543 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new RowCountConstraint(null));544 var builder = builderMockFactory.Object;545 var testCaseFactory = new TestCaseFactory();546 testCaseFactory.Register(typeof(ExecutionXml), typeof(RowCountXml), builder);547 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);548 Assert.That(tc, Is.Not.Null);549 builderMockFactory.VerifyAll();550 }551 [Test]552 public void IsHandling_DataTypeIs_True()553 {554 var sutXml = new DataTypeXml();555 var ctrXml = new IsXml();556 var testCaseFactory = new TestCaseFactory();557 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());558 Assert.That(actual, Is.True);559 }560 [Test]561 public void Instantiate_DataTypeIs_TestCase()562 {563 var sutXml = new DataTypeXml();564 var ctrXml = new IsXml();565 var builderMockFactory = new Mock<ITestCaseBuilder>();566 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));567 builderMockFactory.Setup(b => b.Build());568 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new RelationalCommand(new SqlCommand(), null, null));569 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new IsConstraint("x"));570 var builder = builderMockFactory.Object;571 var testCaseFactory = new TestCaseFactory();572 testCaseFactory.Register(typeof(DataTypeXml), typeof(IsXml), builder);573 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);574 Assert.That(tc, Is.Not.Null);575 builderMockFactory.VerifyAll();576 }577 [Test]578 public void IsHandling_ResultSetReferenceExists_True()579 {580 var sutXml = new ResultSetSystemXml();581 var ctrXml = new LookupExistsXml();582 var testCaseFactory = new TestCaseFactory();583 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());584 Assert.That(actual, Is.True);585 }586 [Test]587 public void Instantiate_ResultSetReferenceExists_TestCase()588 {589 var sutXml = new ResultSetSystemXml();590 var ctrXml = new LookupExistsXml();591 var builderMockFactory = new Mock<ITestCaseBuilder>();592 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));593 builderMockFactory.Setup(b => b.Build());594 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new RelationalCommand(new SqlCommand(), null, null));595 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new IsConstraint("x"));596 var builder = builderMockFactory.Object;597 var testCaseFactory = new TestCaseFactory();598 testCaseFactory.Register(typeof(ResultSetSystemXml), typeof(LookupExistsXml), builder);599 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);600 Assert.That(tc, Is.Not.Null);601 builderMockFactory.VerifyAll();602 }603 [Test]604 public void IsHandling_ExecutionEqualToOld_True()605 {606 var sutXml = new ExecutionXml();607 var ctrXml = new EqualToOldXml();608 var testCaseFactory = new TestCaseFactory();609 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());610 Assert.That(actual, Is.True);611 }612 [Test]613 public void Instantiate_ExecutionEqualToOld_TestCase()614 {615 var sutXml = new ExecutionXml();616 var ctrXml = new EqualToOldXml();617 var builderMockFactory = new Mock<ITestCaseBuilder>();618 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));619 builderMockFactory.Setup(b => b.Build());620 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new RelationalCommand(new SqlCommand(), null, null));621 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new IsConstraint("x"));622 var builder = builderMockFactory.Object;623 var testCaseFactory = new TestCaseFactory();624 testCaseFactory.Register(typeof(ExecutionXml), typeof(EqualToOldXml), builder);625 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);626 Assert.That(tc, Is.Not.Null);627 builderMockFactory.VerifyAll();628 }629 [Test]630 public void Instantiate_ScalarScoreExists_TestCase()631 {632 var sutXml = new ScalarXml();633 var ctrXml = new ScoreXml();634 var builderMockFactory = new Mock<ITestCaseBuilder>();635 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, NBi.Core.Configuration.Configuration.Default, It.IsAny<Dictionary<string, IVariable>>(), It.IsAny<ServiceLocator>()));636 builderMockFactory.Setup(b => b.Build());637 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(1);638 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new ScoreConstraint(1m));639 var builder = builderMockFactory.Object;640 var testCaseFactory = new TestCaseFactory();641 testCaseFactory.Register(typeof(ScalarXml), typeof(ScoreXml), builder);642 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);643 Assert.That(tc, Is.Not.Null);644 builderMockFactory.VerifyAll();645 }646 }647}...
ConstraintFactoryTest.cs
Source:ConstraintFactoryTest.cs
...42 Assert.That(actual, Is.True);43 }44 45 [Test]46 public void Instantiate_QuerySyntacticallyCorrect_TestCase()47 {48 var sutXml = new ExecutionXml();49 var ctrXml = new SyntacticallyCorrectXml();5051 var builderMockFactory = new Mock<ITestCaseBuilder>();52 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));53 builderMockFactory.Setup(b => b.Build());54 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());55 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new SyntacticallyCorrectConstraint());56 var builder = builderMockFactory.Object;5758 var testCaseFactory = new TestCaseFactory();59 testCaseFactory.Register(typeof(ExecutionXml), typeof(SyntacticallyCorrectXml), builder);6061 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);6263 Assert.That(tc, Is.Not.Null);64 builderMockFactory.VerifyAll();6566 }6768 [Test]69 public void IsHandling_MembersSyntacticallyCorrect_False()70 {71 var sutXml = new MembersXml();72 var ctrXml = new SyntacticallyCorrectXml();73 var testCaseFactory = new TestCaseFactory();7475 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());7677 Assert.That(actual, Is.False);78 }7980 [Test]81 public void Instantiate_MembersSyntacticallyCorrect_ArgumentException()82 {83 var sutXml = new MembersXml();84 var ctrXml = new SyntacticallyCorrectXml();85 var testCaseFactory = new TestCaseFactory();8687 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });88 }8990 [Test]91 public void IsHandling_StructureSyntacticallyCorrect_False()92 {93 var sutXml = new StructureXml();94 var ctrXml = new SyntacticallyCorrectXml();95 var testCaseFactory = new TestCaseFactory();9697 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());9899 Assert.That(actual, Is.False);100 }101102 [Test]103 public void Instantiate_StructureSyntacticallyCorrect_ArgumentException()104 {105 var sutXml = new StructureXml();106 var ctrXml = new SyntacticallyCorrectXml();107 var testCaseFactory = new TestCaseFactory();108109 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });110 }111112113 [Test]114 public void IsHandling_QueryFasterThan_True()115 {116 var sutXml = new ExecutionXml();117 var ctrXml = new FasterThanXml();118 var testCaseFactory = new TestCaseFactory();119120 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());121122 Assert.That(actual, Is.True);123 }124125 [Test]126 public void Instantiate_QueryFasterThan_TestCase()127 {128 var sutXml = new ExecutionXml();129 var ctrXml = new FasterThanXml();130131 var builderMockFactory = new Mock<ITestCaseBuilder>();132 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));133 builderMockFactory.Setup(b => b.Build());134 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());135 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new FasterThanConstraint());136 var builder = builderMockFactory.Object;137138 var testCaseFactory = new TestCaseFactory();139 testCaseFactory.Register(typeof(ExecutionXml), typeof(FasterThanXml), builder);140141 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);142143 Assert.That(tc, Is.Not.Null);144 builderMockFactory.VerifyAll();145146 }147148 [Test]149 public void IsHandling_MembersFasterThan_False()150 {151 var sutXml = new MembersXml();152 var ctrXml = new FasterThanXml();153 var testCaseFactory = new TestCaseFactory();154155 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());156157 Assert.That(actual, Is.False);158 }159160 [Test]161 public void Instantiate_MembersFasterThan_ArgumentException()162 {163 var sutXml = new MembersXml();164 var ctrXml = new FasterThanXml();165 var testCaseFactory = new TestCaseFactory();166167 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });168 }169170 [Test]171 public void IsHandling_StructureFasterThan_False()172 {173 var sutXml = new StructureXml();174 var ctrXml = new FasterThanXml();175 var testCaseFactory = new TestCaseFactory();176177 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());178179 Assert.That(actual, Is.False);180 }181182 [Test]183 public void Instantiate_StructureFasterThan_ArgumentException()184 {185 var sutXml = new StructureXml();186 var ctrXml = new FasterThanXml();187 var testCaseFactory = new TestCaseFactory();188189 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });190 }191192 [Test]193 public void IsHandling_QueryEqualTo_True()194 {195 var sutXml = new ExecutionXml();196 var ctrXml = new EqualToXml();197 var testCaseFactory = new TestCaseFactory();198199 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());200201 Assert.That(actual, Is.True);202 }203204 [Test]205 public void Instantiate_QueryEqualTo_TestCase()206 {207 var sutXml = new ExecutionXml();208 var ctrXml = new EqualToXml();209210 var builderMockFactory = new Mock<ITestCaseBuilder>();211 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));212 builderMockFactory.Setup(b => b.Build());213 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());214 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new EqualToConstraint("value"));215 var builder = builderMockFactory.Object;216217 var testCaseFactory = new TestCaseFactory();218 testCaseFactory.Register(typeof(ExecutionXml), typeof(EqualToXml), builder);219220 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);221222 Assert.That(tc, Is.Not.Null);223 builderMockFactory.VerifyAll();224225 }226227 [Test]228 public void IsHandling_MembersEqualTo_False()229 {230 var sutXml = new MembersXml();231 var ctrXml = new EqualToXml();232 var testCaseFactory = new TestCaseFactory();233234 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());235236 Assert.That(actual, Is.False);237 }238239 [Test]240 public void Instantiate_MembersEqualTo_ArgumentException()241 {242 var sutXml = new MembersXml();243 var ctrXml = new EqualToXml();244 var testCaseFactory = new TestCaseFactory();245246 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });247 }248249 [Test]250 public void IsHandling_StructureEqualTo_False()251 {252 var sutXml = new StructureXml();253 var ctrXml = new EqualToXml();254 var testCaseFactory = new TestCaseFactory();255256 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());257258 Assert.That(actual, Is.False);259 }260261 [Test]262 public void Instantiate_StructureEqualTo_ArgumentException()263 {264 var sutXml = new StructureXml();265 var ctrXml = new EqualToXml();266 var testCaseFactory = new TestCaseFactory();267268 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });269 }270271 [Test]272 public void IsHandling_QueryContains_False()273 {274 var sutXml = new ExecutionXml();275 var ctrXml = new ContainXml();276 var testCaseFactory = new TestCaseFactory();277278 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());279280 Assert.That(actual, Is.False);281 }282283 [Test]284 public void Instantiate_QueryContains_ArgumentException()285 {286 var sutXml = new ExecutionXml();287 var ctrXml = new ContainXml();288 var testCaseFactory = new TestCaseFactory();289290 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });291 }292293 [Test]294 public void IsHandling_MembersContains_True()295 {296 var sutXml = new MembersXml();297 var ctrXml = new ContainXml();298 var testCaseFactory = new TestCaseFactory();299300 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());301302 Assert.That(actual, Is.True);303 }304305 [Test]306 public void Instantiate_MembersContains_ArgumentException()307 {308 var sutXml = new MembersXml();309 var ctrXml = new ContainXml();310311 var builderMockFactory = new Mock<ITestCaseBuilder>();312 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));313 builderMockFactory.Setup(b => b.Build());314 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());315 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.ContainConstraint("expected"));316 var builder = builderMockFactory.Object;317318 var testCaseFactory = new TestCaseFactory();319 testCaseFactory.Register(typeof(MembersXml), typeof(ContainXml), builder);320321 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);322323 Assert.That(tc, Is.Not.Null);324 builderMockFactory.VerifyAll();325 }326327 [Test]328 public void IsHandling_StructureContains_True()329 {330 var sutXml = new StructureXml();331 var ctrXml = new ContainXml();332 var testCaseFactory = new TestCaseFactory();333334 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());335336 Assert.That(actual, Is.True);337 }338339 [Test]340 public void Instantiate_StructureContains_ArgumentException()341 {342 var sutXml = new StructureXml();343 var ctrXml = new ContainXml();344 var builderMockFactory = new Mock<ITestCaseBuilder>();345 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));346 builderMockFactory.Setup(b => b.Build());347 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());348 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Structure.ContainConstraint("expected"));349 var builder = builderMockFactory.Object;350351 var testCaseFactory = new TestCaseFactory();352 testCaseFactory.Register(typeof(StructureXml), typeof(ContainXml), builder);353354 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);355356 Assert.That(tc, Is.Not.Null);357 builderMockFactory.VerifyAll();358 }359360 [Test]361 public void IsHandling_QueryCount_False()362 {363 var sutXml = new ExecutionXml();364 var ctrXml = new CountXml();365 var testCaseFactory = new TestCaseFactory();366367 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());368369 Assert.That(actual, Is.False);370 }371372 [Test]373 public void Instantiate_QueryCount_ArgumentException()374 {375 var sutXml = new ExecutionXml();376 var ctrXml = new CountXml();377 var testCaseFactory = new TestCaseFactory();378379 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });380 }381382 [Test]383 public void IsHandling_MembersCount_True()384 {385 var sutXml = new MembersXml();386 var ctrXml = new CountXml();387 var testCaseFactory = new TestCaseFactory();388389 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());390391 Assert.That(actual, Is.True);392 }393394 [Test]395 public void Instantiate_MembersCount_ArgumentException()396 {397 var sutXml = new MembersXml();398 var ctrXml = new CountXml();399400 var builderMockFactory = new Mock<ITestCaseBuilder>();401 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));402 builderMockFactory.Setup(b => b.Build());403 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());404 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new CountConstraint());405 var builder = builderMockFactory.Object;406407 var testCaseFactory = new TestCaseFactory();408 testCaseFactory.Register(typeof(MembersXml), typeof(CountXml), builder);409410 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);411412 Assert.That(tc, Is.Not.Null);413 builderMockFactory.VerifyAll();414 }415416 [Test]417 public void IsHandling_StructureCount_True()418 {419 var sutXml = new StructureXml();420 var ctrXml = new CountXml();421 var testCaseFactory = new TestCaseFactory();422423 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());424425 Assert.That(actual, Is.False);426 }427428 [Test]429 public void Instantiate_StructureCount_ArgumentException()430 {431 var sutXml = new StructureXml();432 var ctrXml = new CountXml();433 var testCaseFactory = new TestCaseFactory();434435 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });436 }437438 [Test]439 public void IsHandling_QueryOrdered_False()440 {441 var sutXml = new ExecutionXml();442 var ctrXml = new OrderedXml();443 var testCaseFactory = new TestCaseFactory();444445 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());446447 Assert.That(actual, Is.False);448 }449450 [Test]451 public void Instantiate_QueryOrdered_ArgumentException()452 {453 var sutXml = new ExecutionXml();454 var ctrXml = new OrderedXml();455 var testCaseFactory = new TestCaseFactory();456457 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });458 }459460 [Test]461 public void IsHandling_MembersOrdered_True()462 {463 var sutXml = new MembersXml();464 var ctrXml = new OrderedXml();465 var testCaseFactory = new TestCaseFactory();466467 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());468469 Assert.That(actual, Is.True);470 }471472 [Test]473 public void Instantiate_MembersOrdered_ArgumentException()474 {475 var sutXml = new MembersXml();476 var ctrXml = new OrderedXml();477478 var builderMockFactory = new Mock<ITestCaseBuilder>();479 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));480 builderMockFactory.Setup(b => b.Build());481 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());482 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new OrderedConstraint());483 var builder = builderMockFactory.Object;484485 var testCaseFactory = new TestCaseFactory();486 testCaseFactory.Register(typeof(MembersXml), typeof(OrderedXml), builder);487488 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);489490 Assert.That(tc, Is.Not.Null);491 builderMockFactory.VerifyAll();492 }493494 [Test]495 public void IsHandling_StructureOrdered_True()496 {497 var sutXml = new StructureXml();498 var ctrXml = new OrderedXml();499 var testCaseFactory = new TestCaseFactory();500501 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());502503 Assert.That(actual, Is.False);504 }505506 [Test]507 public void Instantiate_StructureOrdered_ArgumentException()508 {509 var sutXml = new StructureXml();510 var ctrXml = new OrderedXml();511 var testCaseFactory = new TestCaseFactory();512513 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });514 }515516517 [Test]518 public void IsHandling_QueryExists_False()519 {520 var sutXml = new ExecutionXml();521 var ctrXml = new ExistsXml();522 var testCaseFactory = new TestCaseFactory();523524 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());525526 Assert.That(actual, Is.False);527 }528529 [Test]530 public void Instantiate_QueryExists_ArgumentException()531 {532 var sutXml = new ExecutionXml();533 var ctrXml = new ExistsXml();534 var testCaseFactory = new TestCaseFactory();535536 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });537 }538539 [Test]540 public void IsHandling_MembersExists_False()541 {542 var sutXml = new MembersXml();543 var ctrXml = new ExistsXml();544 var testCaseFactory = new TestCaseFactory();545546 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());547548 Assert.That(actual, Is.False);549 }550551 [Test]552 public void Instantiate_MembersExists_ArgumentException()553 {554 var sutXml = new MembersXml();555 var ctrXml = new ExistsXml();556557 var testCaseFactory = new TestCaseFactory();558559 Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });560 }561562 [Test]563 public void IsHandling_StructureExists_True()564 {565 var sutXml = new StructureXml();566 var ctrXml = new ExistsXml();567 var testCaseFactory = new TestCaseFactory();568569 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());570571 Assert.That(actual, Is.True);572 }573574 [Test]575 public void Instantiate_StructureExists_TestCase()576 {577 var sutXml = new StructureXml();578 var ctrXml = new ExistsXml();579 var builderMockFactory = new Mock<ITestCaseBuilder>();580 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));581 builderMockFactory.Setup(b => b.Build());582 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());583 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new ExistsConstraint());584 var builder = builderMockFactory.Object;585586 var testCaseFactory = new TestCaseFactory();587 testCaseFactory.Register(typeof(StructureXml), typeof(ExistsXml), builder);588589 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);590591 Assert.That(tc, Is.Not.Null);592 builderMockFactory.VerifyAll();593 }594595596 [Test]597 public void IsHandling_MembersMatchPattern_True()598 {599 var sutXml = new MembersXml();600 var ctrXml = new MatchPatternXml();601 var testCaseFactory = new TestCaseFactory();602603 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());604605 Assert.That(actual, Is.True);606 }607608 [Test]609 public void Instantiate_MembersMatchPattern_TestCase()610 {611 var sutXml = new MembersXml();612 var ctrXml = new MatchPatternXml();613 var builderMockFactory = new Mock<ITestCaseBuilder>();614 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));615 builderMockFactory.Setup(b => b.Build());616 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());617 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Member.MatchPatternConstraint());618 var builder = builderMockFactory.Object;619620 var testCaseFactory = new TestCaseFactory();621 testCaseFactory.Register(typeof(MembersXml), typeof(MatchPatternXml), builder);622623 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);624625 Assert.That(tc, Is.Not.Null);626 builderMockFactory.VerifyAll();627 }628629 [Test]630 public void IsHandling_ExecutionMatchPattern_True()631 {632 var sutXml = new ExecutionXml();633 var ctrXml = new MatchPatternXml();634 var testCaseFactory = new TestCaseFactory();635636 var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());637638 Assert.That(actual, Is.True);639 }640641 [Test]642 public void Instantiate_ExecutionMatchPattern_TestCase()643 {644 var sutXml = new ExecutionXml();645 var ctrXml = new MatchPatternXml();646647 var builderMockFactory = new Mock<ITestCaseBuilder>();648 builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml));649 builderMockFactory.Setup(b => b.Build());650 builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand());651 builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Query.MatchPatternConstraint());652 var builder = builderMockFactory.Object;653654 var testCaseFactory = new TestCaseFactory();655 testCaseFactory.Register(typeof(ExecutionXml), typeof(MatchPatternXml), builder);656657 var tc = testCaseFactory.Instantiate(sutXml, ctrXml);658659 Assert.That(tc, Is.Not.Null);660 builderMockFactory.VerifyAll();661 }662 }663}
...
TestCaseFactory.cs
Source:TestCaseFactory.cs
...148 /// </summary>149 /// <param name="sutXml"></param>150 /// <param name="ctrXml"></param>151 /// <returns></returns>152 public TestCase Instantiate(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)153 {154 sutXml = sutXml ?? throw new ArgumentNullException("sutXml");155 ctrXml = ctrXml ?? throw new ArgumentNullException("ctrXml");156157 ITestCaseBuilder builder = null;158159 //Look for registration ...160 var registration = registrations.FirstOrDefault(reg => IsRegistered(reg, sutXml.GetType(), ctrXml.GetType()));161 if (registration == null)162 throw new ArgumentException(string.Format("'{0}' is not an expected type for a constraint with a system-under-test '{1}'.", ctrXml.GetType().Name, sutXml.GetType().Name));163164 //Apply the chooser if needed165 if (registration.Builder == null)166 registration.Chooser.Choose(sutXml, ctrXml);
...
Instantiate
Using AI Code Generation
1using NBi.NUnit;2using NBi.NUnit.Builder;3using NBi.NUnit.TestCase;4using NUnit.Framework;5using System;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10{11 {12 public void Instantiate_SqlQueryTestCase()13 {14 var factory = new TestCaseFactory();15 var testCase = factory.Instantiate(typeof(SqlQueryTestCase), new Dictionary<string, object>());16 }17 public void Instantiate_SqlQueryTestCaseBuilder()18 {19 var factory = new TestCaseFactory();20 var testCase = factory.Instantiate(typeof(SqlQueryTestCaseBuilder), new Dictionary<string, object>());21 }22 }23}
Instantiate
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.NUnit;7using NBi.NUnit.Query;8using NBi.Core.ResultSet;9using NBi.Core.Calculation;10using NBi.Core.Calculation.Predicate;11using NBi.Core.Calculation.Ranking;12using NBi.Core.Variable;13{14 {15 public MyFactory() : base(16 new QueryTestCase(17 "SELECT * FROM [dbo].[MyTable];",18 new SettingsResultSet()19 {20 },21 new List<IColumnDefinition>()22 {23 new ColumnDefinition("MyColumn", new BasePredicateFactory(new EqualToFilterFactory()))24 }25 {}26 }27}28SELECT * FROM [dbo].[MyTable];29ColumnDefinition("MyColumn", new BasePredicateFactory(new EqualToFilterFactory()))30{31 [DataSource("MyDataSource")]32 public void MyTest()33 {34 var factory = new MyFactory();35 var testCase = factory.Instantiate();36 testCase.Run();37 }38}39public QueryTestCase(
Instantiate
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using NBi.NUnit;6using NBi.NUnit.Execution;7using NUnit.Framework;8{9 {10 public void InstantiateTest()11 {12 var factory = new TestCaseFactory();13 var testCase = factory.Instantiate("NBi.Testing.Acceptance.NUnit.Execution.TestCaseFactoryTest.xml");14 Assert.That(testCase, Is.Not.Null);15 }16 }17}
Instantiate
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.NUnit.TestCaseFactory;7using NBi.Testing.Integration.NUnit;8using NUnit.Framework;9using NUnit.Core;10using NUnit.Core.Extensibility;11{12 {13 public void TestMethod()14 {15 Assert.AreEqual(1, 1);16 }17 }18}19using System;20using System.Collections.Generic;21using System.Linq;22using System.Text;23using System.Threading.Tasks;24using NBi.NUnit.TestCaseFactory;25using NBi.Testing.Integration.NUnit;26using NUnit.Framework;27using NUnit.Core;28using NUnit.Core.Extensibility;29{30 {31 public void TestMethod()32 {33 Assert.AreEqual(1, 1);34 }35 }36}37using System;38using System.Collections.Generic;39using System.Linq;40using System.Text;41using System.Threading.Tasks;42using NBi.NUnit.TestCaseFactory;43using NBi.Testing.Integration.NUnit;44using NUnit.Framework;45using NUnit.Core;46using NUnit.Core.Extensibility;47{48 {49 public void TestMethod()50 {51 Assert.AreEqual(1, 1);52 }53 }54}55using System;56using System.Collections.Generic;57using System.Linq;58using System.Text;59using System.Threading.Tasks;60using NBi.NUnit.TestCaseFactory;61using NBi.Testing.Integration.NUnit;62using NUnit.Framework;63using NUnit.Core;64using NUnit.Core.Extensibility;65{66 {67 public void TestMethod()68 {69 Assert.AreEqual(1, 1);70 }71 }72}73using System;74using System.Collections.Generic;75using System.Linq;76using System.Text;77using System.Threading.Tasks;
Instantiate
Using AI Code Generation
1using NBi.NUnit;2using NBi.NUnit.Execution;3using NBi.NUnit.Template;4using NBi.Xml.Constraints;5using NBi.Xml.Items;6using NBi.Xml.Systems;7using NBi.Xml;8using System;9using System.Collections.Generic;10{11 {12 static void Main(string[] args)13 {14 var testCases = new List<TestCase>();15 var testCase = new TestCase();16 testCase.Name = "TestCase1";17 testCase.Description = "TestCase1";18 testCase.SystemUnderTest = new SystemUnderTestXml();19 testCase.SystemUnderTest.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";20 testCase.SystemUnderTest.Provider = "sqlserver";21 testCase.SystemUnderTest.Query = "select * from Person.Address";22 testCase.SystemUnderTest.QueryType = "Query";23 testCase.SystemUnderTest.CsvPath = "";24 testCase.SystemUnderTest.CsvSeparator = "";25 var constraint = new EqualToXml();26 constraint.Value = "1";27 var column = new ColumnXml();28 column.Name = "AddressID";29 var columnCollection = new ColumnCollectionXml();30 columnCollection.Add(column);31 constraint.Columns = columnCollection;32 testCase.Assert = constraint;33 testCases.Add(testCase);34 var testSuite = new TestSuite();35 testSuite.TestCases = testCases;36 var factory = new TestCaseFactory();37 var newTestCase = factory.Instantiate(testCase);38 testSuite.TestCases.Add(newTestCase);39 var runner = new TestSuiteRunner(testSuite);40 runner.Run();41 Console.ReadKey();42 }43 }44}45NBi.NUnit.TestCaseFactory.Instantiate Method (NBi.NUnit.Template.TestCaseTemplate)
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!