ria 04 & 05 - first asp.net mvc project
DESCRIPTION
TRANSCRIPT
![Page 1: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/1.jpg)
STAATLICHANERKANNTEFACHHOCHSCHULE
Author: Dip.-Inf. (FH) Johannes HoppeDate: 27.10.2010
10.11.2010
STUDIERENUND DURCHSTARTEN.
![Page 2: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/2.jpg)
STAATLICHANERKANNTEFACHHOCHSCHULE
RIA – Rich Internet Applications
Author: Dip.-Inf. (FH) Johannes HoppeDate: 27.10.2010
10.11.2010
![Page 3: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/3.jpg)
First ASP.NET Project: WebNoteMvc
0109.04.2023
Folie 3
![Page 4: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/4.jpg)
First ASP.NET Project: WebNoteMvc
09.04.2023
Folie 4
View(Presentation)
Controller Layer(Application flow controll)
Model(Business Layer)
Service Layer
Repository Layer
Data Access Layer
![Page 5: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/5.jpg)
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)
09.04.2023
Folie 5
![Page 6: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/6.jpg)
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
09.04.2023
Folie 6
![Page 7: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/7.jpg)
Repetition of creating “WebNoteMvc”
0209.04.2023
Folie 7
![Page 8: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/8.jpg)
Repetition of creating “WebNoteMvc”
1. We created a database and a table
09.04.2023
Folie 8
![Page 9: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/9.jpg)
Repetition of creating “WebNoteMvc”
2. We created an EDMX file based on the database
09.04.2023
Folie 9
![Page 10: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/10.jpg)
Repetition of creating “WebNoteMvc”
3. We used the extension ”MCGe v0.3” to generate POCOs
09.04.2023
Folie 10
http://blog.johanneshoppe.de/2010/10/ado-net-mocking-context-generator-extended-walkthrough/
![Page 11: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/11.jpg)
Repetition of creating “WebNoteMvc”
3. We used the extension ”MCGe v0.3” to generate POCOs
09.04.2023
Folie 11
![Page 12: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/12.jpg)
Repetition of creating “WebNoteMvc”
4. We created a repository layer with all CRUD operations
09.04.2023
Folie 12
![Page 13: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/13.jpg)
Repetition of creating “WebNoteMvc”
5. We changed the default controller to provide all CRUD operations
09.04.2023
Folie 13
![Page 14: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/14.jpg)
Repetition of creating “WebNoteMvc”
6. We created views for every Controller operation
09.04.2023
Folie 14
![Page 15: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/15.jpg)
Repetition of creating “WebNoteMvc”
09.04.2023
Folie 15
![Page 16: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/16.jpg)
Repetition of creating “WebNoteMvc”
Questions?
?
09.04.2023
Folie 16
![Page 17: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/17.jpg)
Unit Tests
0309.04.2023
Folie 17
![Page 18: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/18.jpg)
Unit Tests
What?Why?
When?How?
09.04.2023
Folie 18
![Page 19: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/19.jpg)
Unit Tests
What?
A piece of softwarethat (automatically)tests the smallest parts of an application.
09.04.2023
Folie 19
![Page 20: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/20.jpg)
Unit Tests
What?
A unit test enables you to verifywhether a particular method
works as you intend it to work.
09.04.2023
Folie 20
![Page 21: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/21.jpg)
Unit Tests
What?
A unit test is a straightforwardway to produce code
with a low error rate.
09.04.2023
Folie 21
![Page 22: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/22.jpg)
Unit Tests
Why?
09.04.2023
Folie 22
![Page 23: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/23.jpg)
Unit Tests
09.04.2023
Folie 23
Building tests for your code
avoids software bugs.
![Page 24: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/24.jpg)
Unit Tests
09.04.2023
Folie 24
Building tests for your code
provides you with a safety net for change.
![Page 25: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/25.jpg)
Unit Tests
09.04.2023
Folie 25
Building tests for your code
forces you to write loosely coupled code.
![Page 26: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/26.jpg)
Unit Tests
09.04.2023
Folie 26
Building tests for your code
forces you to take a user perspective on the code.
![Page 27: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/27.jpg)
Unit Tests
09.04.2023
Folie 27
Building tests for your code
provides a documentation for future coders.
![Page 28: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/28.jpg)
Unit Tests
When?
09.04.2023
Folie 28
![Page 29: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/29.jpg)
Unit Tests
When?
Always.or
Whenever it is plannedto reuse the software.
09.04.2023
Folie 29
![Page 30: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/30.jpg)
Unit Tests
When?
Beforewriting the actual code.(Test-Driven Development)
09.04.2023
Folie 30
![Page 31: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/31.jpg)
Unit Tests
When?
Test-Driven Development1. Write a unit test that fails.2. Write code that passes the unit tests.3. Refactor your code.
09.04.2023
Folie 31
![Page 32: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/32.jpg)
Unit Tests
09.04.2023
Folie 32
How?
![Page 33: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/33.jpg)
Unit Tests
Questions?
?
09.04.2023
Folie 33
![Page 34: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/34.jpg)
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
09.04.2023
Folie 34
![Page 35: Ria 04 & 05 - First ASP.NET MVC project](https://reader033.vdocuments.net/reader033/viewer/2022061200/547710f6b4af9fad458b4595/html5/thumbnails/35.jpg)
THANK YOUFOR YOUR ATTENTION
09.04.2023
Folie 35