4. First ASP.NET Project: WebNoteMvc
30.01.2015
Folie 4
View
(Presentation)
Controller Layer
(Application flow controll)
Model
(Business Layer)
Service Layer
Repository Layer
Data Access Layer
5. First ASP.NET Project: WebNoteMvc
Tiers for the Model
› Service Layer
› Sub-Applications boundary “Access from outside”
› CRUD, Validation, Transactions…
› A good place to “talk” with other repositories
› Repository Layer
› “Shields” application from real data access
› A good place for caching
› Data Access Layer (here: Entity Framework)
› Data mapper that moves data between objects and a database
(brutally simplified Martin Fowler: Patterns of Enterprise Application Architecture)
30.01.2015
Folie 5
6. First ASP.NET Project: WebNoteMvc
Implementation
› 1. We created a database and a table
› 2. We created an EDMX file based on the database
› 3. We used the plugin ”MCGe” to generate POCOs
› 4. We created a repository layer with all CRUD operations
› We did not created a service layer (for now)
› 5. We changed the default controller to provide all CRUD operations
› 6. We created views for every Controller operation
http://code.google.com/p/lecture-
hoppe/downloads/detail?name=WebNoteMvc_v0.3.zip
30.01.2015
Folie 6
8. Repetition of creating “WebNoteMvc”
1. We created a database and a table
30.01.2015
Folie 8
9. Repetition of creating “WebNoteMvc”
2. We created an EDMX file based on the database
30.01.2015
Folie 9
10. Repetition of creating “WebNoteMvc”
3. We used the extension ”MCGe v0.3” to generate POCOs
30.01.2015
Folie 10
http://blog.johanneshoppe.de/2010/10/ado-net-mocking-context-generator-
extended-walkthrough/
11. Repetition of creating “WebNoteMvc”
3. We used the extension ”MCGe v0.3” to generate POCOs
30.01.2015
Folie 11
12. Repetition of creating “WebNoteMvc”
4. We created a repository layer with all CRUD operations
30.01.2015
Folie 12
13. Repetition of creating “WebNoteMvc”
5. We changed the default controller to provide all CRUD operations
30.01.2015
Folie 13
14. Repetition of creating “WebNoteMvc”
6. We created views for every Controller operation
30.01.2015
Folie 14
34. Unit Tests
Your tasks:
› Try to write your first set of unit tests
› Work together with you neighbor (2 persons, one team)
› Use the Mock-Framework “Moq” from www.moq.me
› Implement:
AddNoteTest, EditNoteTest, DeleteNoteTest
DeleteNoteShouldThrowExceptionTest
GetNoteShouldNotCallSaveChangesTest
6 Tests for the Controller
30.01.2015
Folie 34