TAILIEUCHUNG - Lập trình .net 4.0 và visual studio 2010 part 47

Tất nhiên, một trong những lợi thế lớn nhất của MVC là testability của nó, và không có tổng quan về MVC sẽ được hoàn thành mà không nhìn vào chức năng này. Lưu ý rằng chức năng này không sẵn có ở tất cả các phiên bản của Visual Studio. Một cách khác là sử dụng một khuôn khổ mã nguồn mở như NUnit (mà được cho là tốt hơn nhiều hỗ trợ và tài liệu, anyway). | CHAPTER 13 MVC namespace public static class UrlHelperExtension public static string AllFilms this UrlHelper helper return Film All You can then use this as follows a href All Films a Filters MVC allows the creation of reusable blocks of code called filters that intercept and process various types of requests. Common uses of filters include authorization and logging. For information on overriding controller classes and views see the Further Reading section at the end of the chapter. Testing Of course one of the biggest advantages of MVC is its testability and no overview of MVC would be complete without looking at this functionality. Note that this functionality is not available in all versions of Visual Studio. An alternative is to use an open source framework such as NUnit which is arguably much better supported and documented anyway . Creating a Fake Film Repository To avoid accessing the database you will create a fake class to return films 1. Create a new folder in the project called Support. 2. Add a new class called FakeFilmRepository. 3. Replace the code in with the following using System using using using using 318 CHAPTER 13 MVC namespace public class FakeFilmRepository IFilmRepository public List Film Films new List Film region IFilmRepository Members public bool Add Film film throw new NotImplementedException public Film Create throw new NotImplementedException public void Delete int ID throw new NotImplementedException public IEnumerable Film GetAll return Films public Film GetFilm int FilmID return f FilmID public void Save throw new NotImplementedException public bool Update Film film throw new NotImplementedException endregion Creating a Test When you first created the project Visual Studio asked whether you .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.