????????????????е?????????????????

????????????PageRepository??и???????????????仯?????????????????????????????и????????????????????????????????????????????????????????????????????????????????з?????????????????????????????????????齫?????
????[Specification]
????public void GetPage_Should_Return_A_Page_from_cache_when_it_is_already_cached()
????{
????var cache = new Mock();
????var database = new Mock();
????IPageRepository pageRepository = new PageRepository(database.Object?? cache.Object);
????const int pageId = 1;
????var page = default(Page);
????var samplePage = new Page() { ID = pageId?? Title = "Test Page"??
????ColumnCount = 3?? LayoutType = 3?? UserId = Guid.Empty?? VersionNo = 1??
????PageType = Enumerations.PageTypeEnum.PersonalPage??
????CreatedDate = DateTime.Now };
????"Given PageRepository and the requested page in cache".Context(() =>
????{
????cache.Expect(c => c.Get(CacheSetup.CacheKeys.PageId(samplePage.ID)))
????.Returns(samplePage);
????});
????"when GetPageById is called".Do(() =>
????page = pageRepository.GetPageById(1));           
????"it checks in the cache first and finds the object is in cache".Assert(() =>
????{
????cache.VerifyAll();
????});
????"it returns the page as expected".Assert(() =>
????{
????Assert.Equal(pageId?? page.ID);
????});
????}
????????????????????????????????Context ???????趨?????????????????????????????????????samplePage???????????κα????ú???????????????????Mock???????????????????????????κ?database??????κζ??????????cache???????????????????????????????????????????????
??????????????BDD
?????????????ζ???????????Щ??????????????????????????????????????????????????????д????????????????????????????????κ????????????????????????????????????????б????????????????????????
??????β?????????????????????????????????????????ó???????????????????????????????????????????磬??Dropthings ???????????μ?????????????????????????????С????????Щ????С?????????????塣????????anon_user@dropthings.com???????????????????С?????????????????????С?????????????????????С?????????????????????????????????????????
???????????η????Default.aspx????FirstVisitHomePage?????Facade????????????????????????????楨С????????????????????????????????????FirstVisitHomePage?????ò??????????μ??????????????????????????????????????????????????????????? ??????????????????????????????????? ?????????η???? ??????????к?λ?????anon_user??????′???????洴????С??????
????public class TestUserVisit
????{
????public TestUserVisit()
????{
????Facade.BootStrap();
????}
????///
????/// Ensure the first visit produces the pages and widgets defined in the template user
????///
????[Specification] public void First_visit_should_create_same_pages_and_widgets_as_the_template_user() { MembershipHelper.UsingNewAnonUser((profile) => { using (var facade = new Facade(new AppContext(string.Empty?? profile.UserName))) { UserSetup userVisitModel = null; // Load the anonymous user pages and widgets string anonUserName = facade.GetUserSettingTemplate() .AnonUserSettingTemplate.UserName; var anonPages = facade.GetPagesOfUser(facade.GetUserGuidFromUserName(anonUserName)); "Given anonymous user who has never visited the site before" .Context(() => { }); "when the user visits for the first time".Do(() => { userVisitModel = facade.FirstVisitHomePage(profile.UserName?? string.Empty?? true?? false); }); "it creates widgets on the newly created page at exact columns and positions as the anon user's pages".Assert(() => { anonPages.Each(anonPage => { var userPage = userVisitModel.UserPages.First(page => page.Title == anonPage.Title && page.OrderNo == anonPage.OrderNo && page.PageType == anonPage.PageType); facade.GetColumnsInPage(anonPage.ID).Each(anonColumn => { var userColumns = facade.GetColumnsInPage(userPage.ID); var userColumn = userColumns.First(column => column.ColumnNo == anonColumn.ColumnNo); var anonColumnWidgets = facade.GetWidgetInstancesInZoneWithWidget(anonColumn.WidgetZoneId); var userColumnWidgets = facade.GetWidgetInstancesInZoneWithWidget(userColumn.WidgetZoneId); // Ensure the widgets from the anonymous user template's columns are // in the same column and row. anonColumnWidgets.Each(anonWidget => Assert.True(userColumnWidgets.Where(userWidget => userWidget.Title == anonWidget.Title && userWidget.Expanded == anonWidget.Expanded && userWidget.State == anonWidget.State && userWidget.Resized == anonWidget.Resized && userWidget.Height == anonWidget.Height && userWidget.OrderNo == anonWidget.OrderNo).Count() == 1)); }); }); }); } }); }
???????????????????????????????????????????????????????????????????????????檔?????????????????????С??????????????????????????仯???????????????????????????????λ?????????????????м??????????????????????????????????????????????????????κε???? ????xunit.console.exe?????е??????????????????????html???棺

??????????????????????в????? d:xunitxunit.console.exe d: runksrcDropthings.Business.Facade.TestsinDebugDropthings.Business.Facade.Tests.dll /html FacadeTest.html
?????????????GUI xUnit: