A Beginners Guide to Building a RAG App Using Open Source Milvus
Â
prdc10-tdd-patterns
1.
2. AMIR BARYLKO
TDD PATTERNS
FOR .NET DEVELOPERS
PRAIRIE DEV CON
REGINA 2010
Amir Barylko - TDD Patterns MavenThought Inc.
3. WHO AM I?
⢠Architect
⢠Developer
⢠Mentor
⢠Great cook
⢠The one whoâs entertaining you for the next hour!
Amir Barylko - TDD Patterns MavenThought Inc.
4. WHY TDD?
⢠Test ďŹrst approach
⢠Quality driven
⢠Easy to refactor
⢠Regression tests as byproduct
⢠Increase developerâs conďŹdence
Amir Barylko - TDD Patterns MavenThought Inc.
6. TOOLS
⢠Testing framework: NUnit, MbUnit, MSpec, MavenThought Testing
⢠Mocking framework: Rhino Mocks, Moq, TypeMock
⢠Test Automation: Scripts that can run the test from the
developer computer.
⢠CI server: Unit test should be run after each commit.
⢠Reports and NotiďŹcations: The team should realize right away
that the tests are broken.
Amir Barylko - TDD Patterns MavenThought Inc.
7. AUTO MOCKING
⢠Automatic dependency creation for SUT
⢠Dictionary of dependencies
⢠Faster setup of tests
⢠Build your own: StructureMap
⢠Or use MavenThought Testing
Amir Barylko - TDD Patterns MavenThought Inc.
9. ONE FEATURE PER TEST
⢠Easy to approach Given That
(arrange)
⢠Easy to understand
When I Run
⢠Easy to maintain
(act)
⢠Enforce Given, When, Then
Then it should ...
(assert)
Amir Barylko - TDD Patterns MavenThought Inc.
10. STATE VERIFICATION
⢠Care about the end state var m = new Library...
⢠Does not validate SUT
transitions Run Test
⢠Verifythe state agains the
m.Count.Should(...)
expected value
Amir Barylko - TDD Patterns MavenThought Inc.
11. BEHAVIOUR VERIFICATION
⢠Checking the expected var m = Mock<...>
behaviour happened
⢠Uses mock objects m.Stub(...)
⢠The behaviour is speciďŹed
for each mock object Run Test
⢠The expected methods
m.AssertWasCalled(...)
should be called
Amir Barylko - TDD Patterns MavenThought Inc.
12. TEST WITH PARAMETERS
[Row(1)]
⢠Avoid duplication and [Row(2)]
repetition void Method(int arg)
[Row(typeof(...))]
⢠Generic Parameters void Method<T>(...)
⢠Parameters Factories [Factory(...)]
void Method(string arg)
⢠Random strings void Method([Random]...)
⢠Random numbers void Method([Random]...,
[Factory]...)
Amir Barylko - TDD Patterns MavenThought Inc.
13. DEPENDENCY INJECTION
⢠Remove hardcoded Initialize dependency
dependencies
⢠Introduces dependency in Stub dependency with
the constructor / setter mock
⢠Easy to test and maintain
Assert the mock is
returned
â˘S OLID
Amir Barylko - TDD Patterns MavenThought Inc.
14. DEPENDENCY LOOKUP
⢠Remove hardcoded Initialize service
dependencies locator
⢠Introduces a factory or Stub to return a mock
service locator
⢠Easy to test and maintain Assert the mock is
returned
â˘S OLID
Amir Barylko - TDD Patterns MavenThought Inc.
15. DATABASE SETUP
⢠Base class to setup the Create Database
database
⢠The test always works with a Populate
clean database
⢠Can be conďŹgured to Store
populate data if needed
Retrieve and Assert
Amir Barylko - TDD Patterns MavenThought Inc.