SlideShare a Scribd company logo
1 of 19
ABOUT MYSELF 
Solutions Principal with Slalom Consulting 
(SharePoint Consulting Practice) having more 
than 10 years’ experience in system analysis, 
architecture, development and deployment of 
state-of-the-art IT solutions, working for diverse 
set of clients, including several of the largest 
financial institutions and supply management 
verticals in the US on Microsoft platform, with 
particular focus on implementing collaborative 
portal solutions utilizing SharePoint Products 
and Technologies. 
Do not Follow Me : @SanjivKSharma
NEW JERSEY SHAREPOINT USER GROUP 
• Different SharePoint discussions each 
month on various topics. Announced on 
meetup.com 
• Meets 4th Tuesday of every month 
• 6pm – 8pm 
• Microsoft Office (MetroPark) 
• 101 Wood Ave, Iselin, NJ 08830 
• http://www.njspug.com
THANK YOU 
EVENT SPONSORS 
• Diamond & Platinum sponsors 
have tables here in the Fireside 
Lounge 
• Please visit them and inquire 
about their products & services 
• Also to be eligible for prizes make 
sure to get your bingo card 
stamped
• What is TDD – Intro and Misguided 
• Challenges with SharePoint 
• Unit Test against SharePoint – How ? 
• Tool Required to Implement 
• Demo 
• Pros and Cons - Conclusion
Test-driven development (TDD) is a software 
development process that relies on the repetition of a 
very short development cycle: 
• First the developer writes an (initially failing) 
automated test case that defines a desired 
improvement or new function, 
• Then produces the minimum amount of code to pass 
that test, and 
• Finally refactors the new code to acceptable standards
• Red: Starting with a test, the test is red, because the 
production code doesn’t even exist 
• Green: From developing the test, it is clear what classes, 
fields and methods are required to satisfy the test. 
Production code is implemented until the test is green. 
Only the minimal implementation that turns the Unit 
Test to green shall be produced! No overhead code. 
• Refactor: After the expectations, expressed through the 
test have been met by the code, it is time to refactor and 
apply the “Software Engineering Principles”
Uncle Bob describing Test Driven Development in terms of 
three simple rules. They are: 
1. You are not allowed to write any production code unless 
it is to make a failing unit test pass. 
2. You are not allowed to write any more of a unit test than 
is sufficient to fail; and compilation failures are failures. 
3. You are not allowed to write any more production code 
than is sufficient to pass the one failing unit test. 
(http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd)
• No enough time to write the tests. 
• Testing isn’t my job, because ………….. 
• Unit tests don’t help me, because ………….. 
• There’s no need to test drive my code, because ………….. 
• Running the tests is a pain, because ………….. 
• I don’t like TDD, because ………….. 
• TDD sucks because …………..
This is a short (and certainly not complete) list of the 
benefits of TDD? 
• Minimizing the debugging time 
• Less bugs Better productivity 
• Improved code quality and confidence 
• Enables future enhancement by ensuring existing 
functionality is maintained (tests) 
• Enforces loose-coupling 
• Any finally … Code is always working 
• Need some up-front architecture decisions, certain types of artefact 
very difficult to back out once in production (e.g. list schema) 
• Tight integration with the underlying platform can make code 
inherently difficult to test
• Ready-Only Mentality 
• Most of the SharePoint API does not implement any interface 
Example: 
public static SPSite GetSiteObject(string url) 
{ 
//Option 1 - New Object 
return new SPSite(url); 
//Option 2 - From Current Context 
return SPContext.Current.Site; 
}
• Can be difficult to maintain discipline under pressure 
• Difficult in brownfield development 
• Difficult without management support
The usual suggestions provided by various MVPs: 
• Use the Model-View-Presenter (MVP) pattern to isolate your business logic 
from the user interface and the data source. 
• Implement interfaces for your view classes and your services (such as 
repository classes). 
• Can also use the Service Locator pattern to decouple your presenter class 
from specific implementations of the services that your presenter uses 
(such as your repository class). 
• Also you can use the any mocking framework to replace the calls to the 
SharePoint Object Model. 
• Some also have suggested to use a local installation of SharePoint, 
populate it with test data, and unit test against it.
Mocking Frameworks for SharePoint Development 
• TypeMock : Mocks sealed objects, static methods and internal constructors 
- required to access various SharePoint Objects 
Easy to learn, author and maintain API. 
Intuitive AAA (Arrange-Act-Assert) API. 
Professional customer support 
The price 
• Microsoft Fake (previously known as Microsoft Mole) : Mocks sealed 
objects and internal constructors - required to access various SharePoint 
Objects. 
Intuitive authoring with Behaved Types – 
Available on in VS Premium (in addition to Ultimate). 
For more info : http://blogs.msdn.com/b/bharry/archive/2013/01/30/announcing-visual-studio-2012- 
update-2-vs2012-2.aspx
SharePoint Timer Job: 
1.Get the Items from list where the “EmailDate” is less than 
today date. 
2.If the Retention Status is Email1/Email2  Send Email only 
3.If the Retention Status is "Archive" 
a.Send Final Email. 
b.Perform action on the document to delete or archive based 
on some metadata flag on some document property.
Pros: 
We have already discussed some benefits of the TDD, but 
Cons: 
• Lots of plumbing - More code and complex project structures 
• Negative and Positive - how far to go with this is hard to define e.g tests for 
invalid urls 
• People only test code they know works 
• People tend to use it as integration test rather than discrete unit tests 
• Bug learning Curve
Business Facing 
Technology Facing 
Supporting 
Team 
Critique Product 
Functional Tests 
Examples 
Story Tests 
Prototypes 
Stimulation 
Unit Tests 
Components Test 
Exploratory Tests 
Scenarios 
Usability Test 
User Acceptance Testing 
Alpha/Beta 
Performance and Load Testing 
Security Testing

More Related Content

More from SharePoint Saturday New Jersey

Exchange Server 2013 and SharePoint Server 2013 Integration
Exchange Server 2013 and SharePoint Server 2013 IntegrationExchange Server 2013 and SharePoint Server 2013 Integration
Exchange Server 2013 and SharePoint Server 2013 Integration
SharePoint Saturday New Jersey
 

More from SharePoint Saturday New Jersey (10)

SharePoint Saturday NJ 2014 Slides
SharePoint Saturday NJ 2014 SlidesSharePoint Saturday NJ 2014 Slides
SharePoint Saturday NJ 2014 Slides
 
Improving the SharePoint Development Process with Continuous Integration
Improving the SharePoint Development Process with Continuous IntegrationImproving the SharePoint Development Process with Continuous Integration
Improving the SharePoint Development Process with Continuous Integration
 
10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..
 
Insights and Monitoring of SharePoint Applications
Insights and Monitoring of SharePoint ApplicationsInsights and Monitoring of SharePoint Applications
Insights and Monitoring of SharePoint Applications
 
Optimizing SQL Server 2012 for SharePoint 2013
Optimizing SQL Server 2012 for SharePoint 2013Optimizing SQL Server 2012 for SharePoint 2013
Optimizing SQL Server 2012 for SharePoint 2013
 
Integrating Office Web Apps with SharePoint 2013
Integrating Office Web Apps with SharePoint 2013Integrating Office Web Apps with SharePoint 2013
Integrating Office Web Apps with SharePoint 2013
 
Anatomy of a mail app
Anatomy of a mail appAnatomy of a mail app
Anatomy of a mail app
 
Exchange Server 2013 and SharePoint Server 2013 Integration
Exchange Server 2013 and SharePoint Server 2013 IntegrationExchange Server 2013 and SharePoint Server 2013 Integration
Exchange Server 2013 and SharePoint Server 2013 Integration
 
Term Store Navigation
Term Store NavigationTerm Store Navigation
Term Store Navigation
 
Business Intelligence
Business IntelligenceBusiness Intelligence
Business Intelligence
 

Recently uploaded

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 

Recently uploaded (20)

Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 

SharePoint Development Tips and Ticks using TDD

  • 1. ABOUT MYSELF Solutions Principal with Slalom Consulting (SharePoint Consulting Practice) having more than 10 years’ experience in system analysis, architecture, development and deployment of state-of-the-art IT solutions, working for diverse set of clients, including several of the largest financial institutions and supply management verticals in the US on Microsoft platform, with particular focus on implementing collaborative portal solutions utilizing SharePoint Products and Technologies. Do not Follow Me : @SanjivKSharma
  • 2. NEW JERSEY SHAREPOINT USER GROUP • Different SharePoint discussions each month on various topics. Announced on meetup.com • Meets 4th Tuesday of every month • 6pm – 8pm • Microsoft Office (MetroPark) • 101 Wood Ave, Iselin, NJ 08830 • http://www.njspug.com
  • 3. THANK YOU EVENT SPONSORS • Diamond & Platinum sponsors have tables here in the Fireside Lounge • Please visit them and inquire about their products & services • Also to be eligible for prizes make sure to get your bingo card stamped
  • 4. • What is TDD – Intro and Misguided • Challenges with SharePoint • Unit Test against SharePoint – How ? • Tool Required to Implement • Demo • Pros and Cons - Conclusion
  • 5. Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: • First the developer writes an (initially failing) automated test case that defines a desired improvement or new function, • Then produces the minimum amount of code to pass that test, and • Finally refactors the new code to acceptable standards
  • 6. • Red: Starting with a test, the test is red, because the production code doesn’t even exist • Green: From developing the test, it is clear what classes, fields and methods are required to satisfy the test. Production code is implemented until the test is green. Only the minimal implementation that turns the Unit Test to green shall be produced! No overhead code. • Refactor: After the expectations, expressed through the test have been met by the code, it is time to refactor and apply the “Software Engineering Principles”
  • 7. Uncle Bob describing Test Driven Development in terms of three simple rules. They are: 1. You are not allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test. (http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd)
  • 8. • No enough time to write the tests. • Testing isn’t my job, because ………….. • Unit tests don’t help me, because ………….. • There’s no need to test drive my code, because ………….. • Running the tests is a pain, because ………….. • I don’t like TDD, because ………….. • TDD sucks because …………..
  • 9. This is a short (and certainly not complete) list of the benefits of TDD? • Minimizing the debugging time • Less bugs Better productivity • Improved code quality and confidence • Enables future enhancement by ensuring existing functionality is maintained (tests) • Enforces loose-coupling • Any finally … Code is always working 
  • 10. • Need some up-front architecture decisions, certain types of artefact very difficult to back out once in production (e.g. list schema) • Tight integration with the underlying platform can make code inherently difficult to test
  • 11. • Ready-Only Mentality • Most of the SharePoint API does not implement any interface Example: public static SPSite GetSiteObject(string url) { //Option 1 - New Object return new SPSite(url); //Option 2 - From Current Context return SPContext.Current.Site; }
  • 12. • Can be difficult to maintain discipline under pressure • Difficult in brownfield development • Difficult without management support
  • 13. The usual suggestions provided by various MVPs: • Use the Model-View-Presenter (MVP) pattern to isolate your business logic from the user interface and the data source. • Implement interfaces for your view classes and your services (such as repository classes). • Can also use the Service Locator pattern to decouple your presenter class from specific implementations of the services that your presenter uses (such as your repository class). • Also you can use the any mocking framework to replace the calls to the SharePoint Object Model. • Some also have suggested to use a local installation of SharePoint, populate it with test data, and unit test against it.
  • 14. Mocking Frameworks for SharePoint Development • TypeMock : Mocks sealed objects, static methods and internal constructors - required to access various SharePoint Objects Easy to learn, author and maintain API. Intuitive AAA (Arrange-Act-Assert) API. Professional customer support The price • Microsoft Fake (previously known as Microsoft Mole) : Mocks sealed objects and internal constructors - required to access various SharePoint Objects. Intuitive authoring with Behaved Types – Available on in VS Premium (in addition to Ultimate). For more info : http://blogs.msdn.com/b/bharry/archive/2013/01/30/announcing-visual-studio-2012- update-2-vs2012-2.aspx
  • 15.
  • 16.
  • 17. SharePoint Timer Job: 1.Get the Items from list where the “EmailDate” is less than today date. 2.If the Retention Status is Email1/Email2  Send Email only 3.If the Retention Status is "Archive" a.Send Final Email. b.Perform action on the document to delete or archive based on some metadata flag on some document property.
  • 18. Pros: We have already discussed some benefits of the TDD, but Cons: • Lots of plumbing - More code and complex project structures • Negative and Positive - how far to go with this is hard to define e.g tests for invalid urls • People only test code they know works • People tend to use it as integration test rather than discrete unit tests • Bug learning Curve
  • 19. Business Facing Technology Facing Supporting Team Critique Product Functional Tests Examples Story Tests Prototypes Stimulation Unit Tests Components Test Exploratory Tests Scenarios Usability Test User Acceptance Testing Alpha/Beta Performance and Load Testing Security Testing