public void SearchForLessEntries() { Catalog catalog = new Catalog(); string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; CatalogEntry entry = new CatalogEntry(Content.Book, entryParams); catalog.Add(entry); AddSomeEntries(catalog, ref entryParams, ref entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); catalog.Add(entry); bool searchIsAccurate = false; IEnumerable <IContent> searchResult = catalog.GetListContent("One", 5); IEnumerable <IContent> all = catalog.GetListContent("One", 30); if (searchResult.Count() == 5 && all.Count() == 11) { searchIsAccurate = true; } Assert.AreEqual(true, searchIsAccurate); }
public void TestAddMultipleSameContentItems() { Catalog catalog = new Catalog(); Content contentBook = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); Content contentBook2 = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); Content contentBook3 = new Content(ContentType.Movie, new string[] { "Leonardo ciffer", "Dan Brown", "23922539", "http://www.introprogramming.info" }); catalog.Add(contentBook); catalog.Add(contentBook3); catalog.Add(contentBook2); Assert.AreEqual(3, catalog.Count); //Count returns 2. I don't know why. // MultiDictionary Count Summary: // Gets the number of key-value pairs in the dictionary. Each value associated // with a given key is counted. If duplicate values are permitted, each duplicate // value is included in the count. }
/// <summary> /// Collect the aggregated style properties of the given element within its context /// </summary> /// <param name="element">A page element, T or OE, or an embedd span from a CDATA wrapper</param> /// <param name="nested">True to look down the hierarchy as well as up</param> /// <returns>A StyleProperties collection</returns> public StyleProperties CollectFrom(XElement element, bool nested = false) { var id = element.Attribute("objectID")?.Value; if (id != null && catalog.ContainsKey(id)) { Hits++; return(catalog[id]); } var properties = new StyleProperties(); if (element.Name.LocalName == "span") { // wrapped CDATA so no connected parent/ancestor to backtrack properties.Add(element.CollectStyleProperties(false)); } else if (element.Name.LocalName == "T") { properties.Add(element.CollectStyleProperties(nested)); properties.Add(CollectFromParagraph(element.Parent)); } else if (element.Name.LocalName == "OE") { properties.Add(CollectFromParagraph(element)); } if (id != null && !catalog.ContainsKey(id)) { catalog.Add(id, properties); } return(properties); }
public void Add_DuplicateAndNonDuplicateItems() { ICatalog catalog = new Catalog(); for (int i = 0; i < 10; ++i) { catalog.Add(new Content(ContentType.Book, new string[] { "TestTitle", "TestAuthor", "432943", @"http://www.testingcatalog.com/" })); } catalog.Add(new Content(ContentType.Application, new string[] { "TestTitle", "TestAppAuthor", "111", @"http://www.testingappcatalog.com/" })); catalog.Add(new Content(ContentType.Movie, new string[] { "TestTitle", "TestMoveAuthor", "22", @"http://www.testingmoviecatalog.com/" })); catalog.Add(new Content(ContentType.Music, new string[] { "TestTitle", "TestMusicAuthor", "3333", @"http://www.testingmusiccatalog.com/" })); IEnumerable<IContent> foundContent = catalog.GetListContent("TestTitle", 100); int numberOfItemsFound = this.CountContentFound(foundContent); Assert.AreEqual(13, numberOfItemsFound); }
public void ExecuteCommand_Update_TwoItemUpdated() { Catalog catalog = new Catalog(); Content item1 = new Content(ContentType.Book, new string[] { "a", "b", "1", "http://google.com" }); catalog.Add(item1); Content item2 = new Content(ContentType.Book, new string[] { "a", "b", "1", "http://google.com" }); catalog.Add(item2); Content item3 = new Content(ContentType.Book, new string[] { "a", "b", "1", "http://abv.bg" }); catalog.Add(item3); Command command = new Command("Update: http://google.com; http://abv.bg"); StringBuilder output = new StringBuilder(); CommandExecutor cmdExecutor = new CommandExecutor(); cmdExecutor.ExecuteCommand(catalog, command, output); Assert.AreEqual("2 items updated", output.ToString().Trim()); }
public CalculateTotalShould() { catalog = new Catalog(); catalog.Add(new Product { Name = "soup", UnitPrice = 1.50m, Markdown = 0.25m }); catalog.Add(new Product { Name = "mushrooms", UnitPrice = 2.0m, Markdown = 1.0m, Special = new Special { BuyCount = 1, SpecialCount = 1, Limit = 0, Ratio = 0.50m } }); catalog.Add(new Product { Name = "munster cheese", UnitPrice = 4.0m, Markdown = 0.0m, Special = new Special { BuyCount = 2, SpecialCount = 1, Limit = 1, Ratio = 0.0m } }); }
public static void Main() { string userAclCode = "SHSchool.Evaluation.ImportProgramPlan"; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"].Size = RibbonBarButton.MenuButtonSize.Large; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"].Image = Properties.Resources.Import_Image; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"]["匯入課程規劃"].Enable = UserAcl.Current[userAclCode].Executable; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"]["匯入課程規劃"].Click += (sender, e) => new ImportProgramPlan().Execute(); Catalog catalog01 = RoleAclSource.Instance["教務作業"]["功能按鈕"]; catalog01.Add(new RibbonFeature(userAclCode, "匯入課程規劃")); string importUserAclCode = "BE85970C-8EB6-4885-BBCF-71EFE7BDFD61"; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"].Size = RibbonBarButton.MenuButtonSize.Large; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"].Image = Properties.Resources.Import_Image; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"]["匯入課程規劃(108年度開始適用)"].Enable = UserAcl.Current[importUserAclCode].Executable; MotherForm.RibbonBarItems["教務作業", "資料統計"]["匯入"]["匯入課程規劃(108年度開始適用)"].Click += delegate { (new ImportCurriculumMappingForm()).ShowDialog(); }; Catalog catalog2 = RoleAclSource.Instance["教務作業"]["功能按鈕"]; catalog01.Add(new RibbonFeature(importUserAclCode, "匯入課程規劃(108年度開始適用)")); }
public void AddSingleAndDuplicate() { Catalog catalog = new Catalog(); catalog.Add(new Content( ContentType.Application, "Java", "Pesho", 5, "http://pesho.com/" )); catalog.Add(new Content( ContentType.Application, "C#", "Nakov", 7, "http://nakov.com/" )); catalog.Add(new Content( ContentType.Application, "C#", "Nakov", 7, "http://nakov.com/" )); Content content = new Content(ContentType.Application, "Python", "Gosho", 12, "http://gosho.com/"); catalog.Add(content); catalog.Add(content); int expected = 5; int actual = catalog.Count; Assert.AreEqual(expected, actual); }
static public void Main() { FISCA.ServerModule.AutoManaged("http://module.ischool.com.tw/module/193005/K12.Behavior.DisciplineInput/udm.xml"); RibbonBarItem item = MotherForm.RibbonBarItems["學務作業", "線上作業"]; item["設定"]["教師獎懲登錄設定"].Enable = Permissions.教師獎懲登錄設定權限; item["設定"].Image = Properties.Resources.設定; item["設定"]["教師獎懲登錄設定"].Click += delegate { new InputDateSettingForm().ShowDialog(); }; Catalog detail1 = RoleAclSource.Instance["學務作業"]; detail1.Add(new RibbonFeature(Permissions.教師獎懲登錄設定, "教師獎懲登錄設定")); item = MotherForm.RibbonBarItems["學務作業", "線上作業"]; item["核可教師獎懲建議"].Image = Properties.Resources.核可教師獎懲建議; item["核可教師獎懲建議"].Size = RibbonBarButton.MenuButtonSize.Medium; item["核可教師獎懲建議"].Enable = Permissions.核可教師獎懲建議權限; item["核可教師獎懲建議"].Click += delegate { new ApprovedForm().ShowDialog(); }; detail1 = RoleAclSource.Instance["學務作業"]; detail1.Add(new RibbonFeature(Permissions.核可教師獎懲建議, "核可教師獎懲建議")); }
public void Add_AddTwoIndenticalBooksAndThreeOtherItems() { string[] testBookContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testBookContent = new Content(ContentType.Book, testBookContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testBookContent); currentCatalog.Add(testBookContent); string[] testMovieContentParams = new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" }; IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams); currentCatalog.Add(testMovieContent); string[] testApplicationContentParams = new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" }; IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams); currentCatalog.Add(testApplicationContent); string[] testSongContentParams = new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" }; IContent testSongContent = new Content(ContentType.Book, testSongContentParams); currentCatalog.Add(testSongContent); IEnumerable<IContent> currentContent = currentCatalog.GetListContent("One", 10); int numberOfRenurnedResults = currentContent.Count(); Assert.AreEqual(1, numberOfRenurnedResults); }
public void ExecuteCommand_Find_FourItemsFound() { Catalog catalog = new Catalog(); catalog.Add(new Content(ContentType.Application, new string[] { "a", "b", "1", "c" })); catalog.Add(new Content(ContentType.Book, new string[] { "a", "f", "2", "g" })); catalog.Add(new Content(ContentType.Movie, new string[] { "a", "u", "3", "j" })); catalog.Add(new Content(ContentType.Song, new string[] { "a", "l", "4", "m" })); Command command = new Command("Find: a; 4"); StringBuilder output = new StringBuilder(); CommandExecutor cmdExecutor = new CommandExecutor(); cmdExecutor.ExecuteCommand(catalog, command, output); StringBuilder expected = new StringBuilder(); expected.AppendLine("Application: a; b; 1; c"); expected.AppendLine("Book: a; f; 2; g"); expected.AppendLine("Movie: a; u; 3; j"); expected.AppendLine("Song: a; l; 4; m"); Assert.AreEqual(expected.ToString().Trim(), output.ToString().Trim()); }
public static void Main() { // 匯出課程修課學生 RibbonBarItem rbItemCourseImportExport = K12.Presentation.NLDPanels.Course.RibbonBarItems["資料統計"]; rbItemCourseImportExport["匯出"]["匯出課程修課學生"].Enable = UserAcl.Current["SHSchool.Course.ExportCourseStudent"].Executable; rbItemCourseImportExport["匯出"]["匯出課程修課學生"].Click += delegate { SmartSchool.API.PlugIn.Export.Exporter exporter = new SHEvaluationExtensions.Course.ExportCourseStudents(""); SHEvaluationExtensions.Course.ExportStudentV2 wizard = new SHEvaluationExtensions.Course.ExportStudentV2(exporter.Text, exporter.Image); exporter.InitializeExport(wizard); wizard.ShowDialog(); }; // 匯入課程修課學生 rbItemCourseImportExport["匯入"]["匯入課程修課學生"].Enable = UserAcl.Current["SHSchool.Course.ImportCourseStudent"].Executable; rbItemCourseImportExport["匯入"]["匯入課程修課學生"].Click += delegate { SmartSchool.API.PlugIn.Import.Importer importer = new SHEvaluationExtensions.Course.ImportCourseStudents(""); SHEvaluationExtensions.Course.ImportStudentV2 wizard = new SHEvaluationExtensions.Course.ImportStudentV2(importer.Text, importer.Image); importer.InitializeImport(wizard); wizard.ShowDialog(); }; // 註冊 // 匯出匯入課程修課學生 Catalog catalog1 = RoleAclSource.Instance["課程"]["功能按鈕"]; catalog1.Add(new RibbonFeature("SHSchool.Course.ExportCourseStudent", "匯出課程修課學生")); catalog1.Add(new RibbonFeature("SHSchool.Course.ImportCourseStudent", "匯入課程修課學生")); }
private void CreateCatalog() { catalog = new Catalog(); catalog.Add(new Man("Fowler", "Martin", "Male", "Blue", new DateTime(1963, 1, 10))); catalog.Add(new Man("Kent", "Beck", "Male", "Green", new DateTime(1961, 2, 20))); catalog.Add(new Man("Eoyang", "Glenda", "Female", "Yellow", new DateTime(1960, 1, 1))); }
public static void Main() { #region 屏東免試入學-班級服務表現 RibbonBarItem rbItem1 = MotherForm.RibbonBarItems["班級", "資料統計"]; rbItem1["報表"]["屏東免試入學"]["班級服務表現"].Enable = UserAcl.Current["CDBF4D69-AD83-46AB-8F2B-7DEE4ADD03AE"].Executable; rbItem1["報表"]["屏東免試入學"]["班級服務表現"].Click += delegate { if (K12.Presentation.NLDPanels.Class.SelectedSource.Count > 0) { ServiceReportForm srf = new ServiceReportForm(); srf.SetClassIDs(K12.Presentation.NLDPanels.Class.SelectedSource); srf.ShowDialog(); } else { FISCA.Presentation.Controls.MsgBox.Show("請選擇選班級"); return; } }; // 屏東免試入學-班級服務表現 Catalog catalog1 = RoleAclSource.Instance["班級"]["功能按鈕"]; catalog1.Add(new RibbonFeature("CDBF4D69-AD83-46AB-8F2B-7DEE4ADD03AE", "屏東免試入學-班級服務表現")); #endregion #region 送審用匯入檔 RibbonBarItem rbItem2 = MotherForm.RibbonBarItems["教務作業", "資料統計"]; rbItem2["報表"]["屏東免試入學"]["送審用匯入檔"].Enable = UserAcl.Current["D67C5AB8-4DBB-413A-9688-DD9F0075B479"].Executable; rbItem2["報表"]["屏東免試入學"]["送審用匯入檔"].Click += delegate { SubmitForReviewForm sfr = new SubmitForReviewForm(); sfr.ShowDialog(); }; // 屏東免試入學-送審用匯入檔 Catalog catalog2 = RoleAclSource.Instance["教務作業"]["功能按鈕"]; catalog2.Add(new RibbonFeature("D67C5AB8-4DBB-413A-9688-DD9F0075B479", "屏東免試入學-送審用匯入檔")); #endregion #region 設定幹部限制 RibbonBarItem rbItem3 = MotherForm.RibbonBarItems["教務作業", "資料統計"]; rbItem2["報表"]["屏東免試入學"]["設定幹部限制"].Enable = UserAcl.Current["8443B0A6-A7B6-478B-9120-63C4F7B6AE14"].Executable; rbItem2["報表"]["屏東免試入學"]["設定幹部限制"].Click += delegate { setCadreNameForm scnf = new setCadreNameForm(); scnf.ShowDialog(); }; // 屏東免試入學-設定幹部限制 Catalog catalog3 = RoleAclSource.Instance["教務作業"]["功能按鈕"]; catalog2.Add(new RibbonFeature("8443B0A6-A7B6-478B-9120-63C4F7B6AE14", "屏東免試入學-設定幹部限制")); #endregion }
// 啟用國中 private static void StartJHSchool() { // 註冊與載入自訂資料欄位 // 註冊權限 Catalog StudUserDefineDataFuncButtonRoleAcl = RoleAclSource.Instance["學生"]["功能按鈕"]; StudUserDefineDataFuncButtonRoleAcl.Add(new RibbonFeature(strSetUserDefineDataAcl, "設定自訂資料欄位樣版")); StudUserDefineDataFuncButtonRoleAcl.Add(new RibbonFeature(strUserDefineDataExportAcl, "匯出自訂資料欄位")); StudUserDefineDataFuncButtonRoleAcl.Add(new RibbonFeature(strUserDefineDataImportAcl, "匯入自訂資料欄位")); // 設定自訂資料欄位樣版 K12.Presentation.NLDPanels.Student.AddDetailBulider(new FISCA.Presentation.DetailBulider <UserDefineDataItem>()); Catalog detail = RoleAclSource.Instance["學生"]["資料項目"]; detail.Add(new DetailItemFeature(typeof(UserDefineDataItem))); RibbonBarButton rbSetUserDefineData = K12.Presentation.NLDPanels.Student.RibbonBarItems["其它"]["自訂資料欄位管理"]; rbSetUserDefineData.Image = Properties.Resources.windows_save_64; rbSetUserDefineData.Enable = UserAcl.Current[strSetUserDefineDataAcl].Executable; rbSetUserDefineData.Click += delegate { SetUserDefineDataForm sudd = new SetUserDefineDataForm(); sudd.ShowDialog(); }; // 匯出匯入自訂資料欄位 MenuButton rbUserDefDataExport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯出"]["其它相關匯出"]; MenuButton rbUserDefDataImport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯入"]["其它相關匯入"]; // 匯出自訂資料欄位 rbUserDefDataExport["匯出自訂資料欄位"].Enable = UserAcl.Current[strUserDefineDataExportAcl].Executable; rbUserDefDataExport["匯出自訂資料欄位"].Click += delegate { SmartSchool.API.PlugIn.Export.Exporter exporter = new ImportExport.ExportUserDefData(); ImportExport.ExportStudentV2 wizard = new ImportExport.ExportStudentV2(exporter.Text, exporter.Image); exporter.InitializeExport(wizard); wizard.ShowDialog(); }; // 匯入自訂資料欄位 rbUserDefDataImport["匯入自訂資料欄位"].Enable = UserAcl.Current[strUserDefineDataImportAcl].Executable; rbUserDefDataImport["匯入自訂資料欄位"].Click += delegate { SmartSchool.API.PlugIn.Import.Importer importer = new ImportExport.ImportUserDefData(); ImportExport.ImportStudentV2 wizard = new ImportExport.ImportStudentV2(importer.Text, importer.Image); importer.InitializeImport(wizard); wizard.ShowDialog(); }; }
public void TestAddMultipleDifferentContentItems() { Catalog catalog = new Catalog(); Content contentBook = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); Content contentMovie = new Content(ContentType.Movie, new string[] { "Fast and Furious", "American Movies", "92752320", "http://www.fastandfurious.com" }); catalog.Add(contentBook); catalog.Add(contentMovie); Assert.AreEqual(2, catalog.Count); }
public void TestMethodAddDuplicatedItems() { Catalog catalog = new Catalog(); Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(firstItem); Content secondItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(secondItem); Assert.AreEqual(2, catalog.Count); }
public void AddTest_DuplivateElements() { Catalog myTestCatalog = new Catalog(); myTestCatalog.Add(new Content(Contents.Book, new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" })); myTestCatalog.Add(new Content(Contents.Book, new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" })); int expected = 2; Assert.AreEqual(expected, myTestCatalog.Count); }
public async Task From_root_of_the_path() { /* Given */ var collector = new SectionCollector(); await _catalog.Add(_aggregator.Aggregate(CancellationToken.None)); /* When */ await collector.Collect(_catalog); /* Then */ Assert.Single(collector.Sections, section => section.Id == "root"); }
public static void Main() { #region 學生留察通知單 RibbonBarItem StudentReports = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]; //StudentReports["報表"]["學務相關報表"].Image = Properties.Resources.boolean_field_fav_64; StudentReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = Permissions.學生留察通知單權限; StudentReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Click += delegate { new SHSchool.留察通知單.Report("student").Print(); }; #endregion RibbonBarItem ClassReports = K12.Presentation.NLDPanels.Class.RibbonBarItems["資料統計"]; //ClassReports["報表"]["學務相關報表"].Image = Properties.Resources.boolean_field_fav_64; ClassReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = Permissions.班級留察通知單權限; ClassReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Click += delegate { new SHSchool.留察通知單.Report("class").Print(); }; #region 事件 K12.Presentation.NLDPanels.Student.SelectedSourceChanged += delegate { if (K12.Presentation.NLDPanels.Student.SelectedSource.Count <= 0) { StudentReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = false; } else { StudentReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = Permissions.學生留察通知單權限; } }; K12.Presentation.NLDPanels.Class.SelectedSourceChanged += delegate { if (K12.Presentation.NLDPanels.Class.SelectedSource.Count <= 0) { ClassReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = false; } else { ClassReports["報表"]["學務相關報表"]["通知單"]["留察通知單"].Enable = Permissions.班級留察通知單權限; } }; #endregion Catalog ribbon = RoleAclSource.Instance["學生"]["報表"]; ribbon.Add(new RibbonFeature(Permissions.學生留察通知單, "留察通知單")); ribbon = RoleAclSource.Instance["班級"]["報表"]; ribbon.Add(new RibbonFeature(Permissions.班級留察通知單, "留察通知單")); }
public void Add_AddTwoIndenticalBooksAndGetOne() { string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); currentCatalog.Add(testContent); IEnumerable<IContent> currentContent = currentCatalog.GetListContent("Intro C#", 1); int numberOfRenurnedResults = currentContent.Count(); Assert.AreEqual(1, numberOfRenurnedResults); }
public void MyCode() { BookCatalog books = new BookCatalog(); books.Add(new Book("ISBN123", "War and Peace", "Tolstoj", 882)); books.Add(new Book("ISBN456", "It", "King", 587)); // books.AddBook(new Book("ISBN456", "It", "King", 587)); Catalog <int, DVD> dvds = new Catalog <int, DVD>(); dvds.Add(new DVD(17, "Heat", 153)); dvds.Add(new DVD(32, "Se7en", 110)); }
public void UpdateContentTest_OneUpdate() { Catalog myTestCatalog = new Catalog(); myTestCatalog.Add(new Content(Contents.Book, new string[] { "Two", "Meta", "8341120", "http://goo.gl/dIkth7gs" })); myTestCatalog.Add(new Content(Contents.Book, new string[] { "Three", "fou", "8342120", "http://goao.gl/daeIkth7gs" })); myTestCatalog.Add(new Content(Contents.Book, new string[] { "Foo", "Bar", "8341126", "http://goao.gl/dIkth7gs" })); int expected = 1; int updated = myTestCatalog.UpdateContent("http://goo.gl/dIkth7gs", "UPDATER"); Assert.AreEqual(expected, updated); }
public static void Main() { var catalog = new Catalog(); catalog.Add(Divisor: 15, Output: "FizzBuzz"); catalog.Add(Divisor: 3, Output: "Fizz"); catalog.Add(Divisor: 5, Output: "Buzz"); var counter = new Counter(Min: 1, Max: 100, Catalog: catalog); counter.Output(); Console.ReadLine(); }
public void AddDuplicateReference() { Catalog catalog = new Catalog(); Content content = new Content(ContentType.Application, "C#", "Nakov", 7, "http://nakov.com/"); catalog.Add(content); catalog.Add(content); int expected = 2; int actual = catalog.Count; Assert.AreEqual(expected, actual); }
public void TestMethodAddMultipleItems() { Catalog catalog = new Catalog(); Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(firstItem); Content secondItem = new Content(ContentType.Movie, new string[] { "Intro C# Movie", "Kiril Petrov", "12231331", "http://www.introprogramming.info/movie" }); catalog.Add(secondItem); Content thirdItem = new Content(ContentType.Song, new string[] { "Intro C# Song", "Petar Petrov", "12444455", "http://www.introprogramming.info/song" }); catalog.Add(thirdItem); Assert.AreEqual(3, catalog.Count); }
public void TestAddTwiseTheSameItem() { Catalog catalog = new Catalog(); catalog.Add(new ContentItem(ItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" })); catalog.Add(new ContentItem(ItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" })); int resultCount = catalog.CountContentByTitle; Assert.AreEqual(resultCount, 2); }
public static void Main() { RibbonBarItem rbItem = FISCA.Presentation.MotherForm.RibbonBarItems["課程", "讀卡"]; RibbonBarButton importButton = rbItem["匯入讀卡成績"]; importButton.Size = RibbonBarButton.MenuButtonSize.Large; importButton.Enable = User.Acl["KaoHsiung.JHEvaluation.Course.ReaderScoreImport01"].Executable; importButton.Image = Properties.Resources.proyector_save_64; importButton.Click += delegate { ImportStartupForm form = new ImportStartupForm(); form.ShowDialog(); }; RibbonBarButton classButton = rbItem["班級代碼設定"]; classButton.Size = RibbonBarButton.MenuButtonSize.Small; classButton.Enable = User.Acl["KaoHsiung.JHEvaluation.Course.ReaderScoreImport02"].Executable;; classButton.Click += delegate { new ClassCodeConfig().ShowDialog(); }; RibbonBarButton examButton = rbItem["試別代碼設定"]; examButton.Size = RibbonBarButton.MenuButtonSize.Small; examButton.Enable = User.Acl["KaoHsiung.JHEvaluation.Course.ReaderScoreImport03"].Executable;; examButton.Click += delegate { new ExamCodeConfig().ShowDialog(); }; RibbonBarButton subjectButton = rbItem["科目代碼設定"]; subjectButton.Size = RibbonBarButton.MenuButtonSize.Small; subjectButton.Enable = User.Acl["KaoHsiung.JHEvaluation.Course.ReaderScoreImport04"].Executable;; subjectButton.Click += delegate { new SubjectCodeConfig().ShowDialog(); }; Catalog detail = RoleAclSource.Instance["課程"]["功能按鈕"]; detail.Add(new ReportFeature("KaoHsiung.JHEvaluation.Course.ReaderScoreImport01", "匯入讀卡成績")); detail.Add(new ReportFeature("KaoHsiung.JHEvaluation.Course.ReaderScoreImport02", "班級代碼設定")); detail.Add(new ReportFeature("KaoHsiung.JHEvaluation.Course.ReaderScoreImport03", "試別代碼設定")); detail.Add(new ReportFeature("KaoHsiung.JHEvaluation.Course.ReaderScoreImport04", "科目代碼設定")); }
public static void Main() { RibbonBarItem rbItem = FISCA.Presentation.MotherForm.RibbonBarItems["課程", "讀卡"]; RibbonBarButton importButton = rbItem["匯入讀卡成績"]; importButton.Size = RibbonBarButton.MenuButtonSize.Large; importButton.Enable = Permissions.匯入讀卡成績權限; importButton.Image = Properties.Resources.byte_add_64; importButton.Click += delegate { ImportStartupForm form = new ImportStartupForm(); form.ShowDialog(); }; RibbonBarButton classButton = rbItem["班級代碼設定"]; classButton.Size = RibbonBarButton.MenuButtonSize.Small; classButton.Enable = Permissions.班級代碼設定權限; classButton.Click += delegate { new ClassCodeConfig().ShowDialog(); }; RibbonBarButton examButton = rbItem["試別代碼設定"]; examButton.Size = RibbonBarButton.MenuButtonSize.Small; examButton.Enable = Permissions.試別代碼設定權限; examButton.Click += delegate { new ExamCodeConfig().ShowDialog(); }; RibbonBarButton subjectButton = rbItem["科目代碼設定"]; subjectButton.Size = RibbonBarButton.MenuButtonSize.Small; subjectButton.Enable = Permissions.科目代碼設定權限; subjectButton.Click += delegate { new SubjectCodeConfig().ShowDialog(); }; Catalog detail = RoleAclSource.Instance["課程"]["功能按鈕"]; detail.Add(new ReportFeature(Permissions.匯入讀卡成績, "匯入讀卡成績")); detail.Add(new ReportFeature(Permissions.班級代碼設定, "班級代碼設定")); detail.Add(new ReportFeature(Permissions.試別代碼設定, "試別代碼設定")); detail.Add(new ReportFeature(Permissions.科目代碼設定, "科目代碼設定")); }
public void CatalogAddTest_DuplicatedElements() { Catalog catalog = new Catalog(); var item = new ContentItem(ContentItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); var item1 = new ContentItem(ContentItemType.Book, new string[] { "Intro Java", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item); catalog.Add(item); catalog.Add(item1); Assert.AreEqual(2, catalog.Count); }
public AddShould() { _catalog = new Catalog(); _catalog.Add(new Product { Name = "cheese wheel", UnitPrice = 1.0m }); _catalog.Add(new Product { Name = "donut", UnitPrice = 2.0m }); _catalog.Add(new Product { Name = "pizza", UnitPrice = 10.0m }); _basket = new Basket(_catalog); }
public void TestMethodAddDuplicateItem() { Catalog catalog = new Catalog(); ContentItem item1 = new ContentItem(ContentItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item1); catalog.Add(item1); ContentItem item2 = new ContentItem(ContentItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item2); Assert.AreEqual(3, catalog.Count); }
public static void Main() { // 學生會考報名檔 MotherForm.RibbonBarItems["教務作業", "十二年國教"]["學生會考報名檔"].Enable = UserAcl.Current["ischoolJHWishBase.ExportExcessCreditsBaseData"].Executable; MotherForm.RibbonBarItems["教務作業", "十二年國教"]["學生會考報名檔"].Click += delegate { ExportExcessCreditsBaseData eecbd = new ExportExcessCreditsBaseData(false); eecbd.ShowDialog(); }; // K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["報表"]["學籍相關報表"]["學生會考報名檔"].Enable = UserAcl.Current["ischoolJHWishBase.ExportExcessCreditsBaseDataS"].Executable; K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["報表"]["學籍相關報表"]["學生會考報名檔"].Click += delegate { ExportExcessCreditsBaseData eecbd = new ExportExcessCreditsBaseData(true); eecbd.ShowDialog(); }; // 學生會考報名檔 Catalog catalog04 = RoleAclSource.Instance["教務作業"]["功能按鈕"]; catalog04.Add(new RibbonFeature("ischoolJHWishBase.ExportExcessCreditsBaseData", "學生會考報名檔")); // 學生會考報名檔 Catalog catalog05 = RoleAclSource.Instance["學生"]["報表"]; catalog05.Add(new RibbonFeature("ischoolJHWishBase.ExportExcessCreditsBaseDataS", "學生會考報名檔")); }
public void AddDuplicateValue() { Catalog catalog = new Catalog(); catalog.Add(new Content( ContentType.Application, "C#", "Nakov", 7, "http://nakov.com/" )); catalog.Add(new Content( ContentType.Application, "C#", "Nakov", 7, "http://nakov.com/" )); int expected = 2; int actual = catalog.Count; Assert.AreEqual(expected, actual); }
public void Add_AddOneBookWithParamsNull() { string[] testContentParams = new string[] { null }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); }
public static void Main() { //註冊權限管理項目。 Catalog detail = RoleAclSource.Instance["班級"]["報表"]; detail.Add(new ReportFeature(PermissionCode, "班級評量成績單")); //DeployParameters dparams = ModuleLoader.GetDeployParametsers(typeof(Program), "Mode=KaoHsiung"); //註冊報表功能項目。 MenuButton mb = NLDPanels.Class.RibbonBarItems["資料統計"]["報表"]["成績相關報表"]["班級評量成績單"]; mb.Enable = false; mb.Click += delegate { MainForm.Run(NLDPanels.Class.SelectedSource); }; //權限判斷。 K12.Presentation.NLDPanels.Class.SelectedSourceChanged += delegate { mb.Enable = (K12.Presentation.NLDPanels.Class.SelectedSource.Count > 0) && Framework.User.Acl[PermissionCode].Executable; }; }
static public void Main() { RibbonBarItem item = FISCA.Presentation.MotherForm.RibbonBarItems["學校", "外掛"]; item["領域資料管理"].Enable = false; item["領域資料管理"].Click += delegate { DomainForm from = new DomainForm(); from.ShowDialog(); }; SchoolPanel.SetSchoolPanel.SelectedSourceChanged += delegate { if (SchoolPanel.SetSchoolPanel.SelectedSource.Count > 0 && Permissions.領域資料管理權限) { item["領域資料管理"].Enable = true; } else { item["領域資料管理"].Enable = false; } }; Catalog iCampusManager01 = RoleAclSource.Instance["學校"]["外掛"]; iCampusManager01.Add(new RibbonFeature(Permissions.領域資料管理, "領域資料管理")); }
public void TestMethodAddSingleItem() { Catalog catalog = new Catalog(); Content item = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item); Assert.AreEqual(1, catalog.Count); }
public void TestMethodGetListContent500Items() { Catalog catalog = new Catalog(); for (int i = 0; i < 500; i++) { Content item = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item); } var result = catalog.GetListContent("Intro C#", 500); Assert.AreEqual(result.Count(), 500); }
public void TestMethodAdd500Items() { Catalog catalog = new Catalog(); for (int i = 0; i < 500; i++) { Content item = new Content(ContentType.Book, new string[] { "Intro C#" + (i % 5), "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item); } Assert.AreEqual(500, catalog.Count); }
public void TestMethodAddAndFindItem() { Catalog catalog = new Catalog(); ContentItem item = new ContentItem(ContentItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(item); var result = catalog.GetListContent("Intro C#", 1); Assert.AreEqual(result.Count(), 1); Assert.AreSame(result.First(), item); }
public void Index() { Indexer indexer = new Indexer(new string[] { Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) }); Catalog catalog = new Catalog(); List<string> items = indexer.Index(); foreach (string item in items) { string name = new FileInfo(item).Name; catalog.Add(new CatalogItem() { Path = item, Name = name.Substring(0, name.Length - 4) }); } _catalog = catalog; _catalog.Meta = new CatalogMeta { LastGenerated = DateTime.Now }; }
public void Add_SingleBook() { ICatalog catalog = new Catalog(); catalog.Add(new Content(ContentType.Book, new string[] { "TestTitle", "TestAuthor", "432943", "http://www.testingcatalog.com/" })); IEnumerable<IContent> foundContent = catalog.GetListContent("TestTitle", 10); int numberOfItemsFound = this.CountContentFound(foundContent); Assert.AreEqual(1, numberOfItemsFound); }
public void TestMethodGetListContentDuplicatedItems() { Catalog catalog = new Catalog(); Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(firstItem); Content secondItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(secondItem); var result = catalog.GetListContent("Intro C#", 2); Assert.AreEqual(result.Count(), 2); Assert.AreSame(result.First(), firstItem); }
public void TestMethodAddMultipleItems() { Catalog catalog = new Catalog(); ContentItem book = new ContentItem(ContentItemType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); catalog.Add(book); ContentItem movie1 = new ContentItem(ContentItemType.Movie, new string[] { "Java Movie", "James Gosling", "53265489", "http://www.introprogramming.info" }); catalog.Add(movie1); ContentItem movie2 = new ContentItem(ContentItemType.Movie, new string[] { "Java Movie", "James Gosling", "53265489", "http://www.introprogramming.info" }); catalog.Add(movie2); ContentItem song = new ContentItem(ContentItemType.Song, new string[] { "Java Song", "James Gosling", "2356489253", "http://www.javasong.com/mp3" }); catalog.Add(song); Assert.AreEqual(4, catalog.Count); }
public OfficialStudentRecordReport2010() { reportName = "學籍表(97學年度入學適用)"; reportPath = "資料統計"; // 學生頁籤-->成績相關報表-->學籍表(97學年度入學適用) button_student = RoleAclSource.Instance["學生"]["報表"]; button_student.Add(new RibbonFeature("Student_Button_OfficialStudentRecordReport2010", "學籍表(97學年度入學適用)")); MotherForm.RibbonBarItems["學生", reportPath]["報表"]["成績相關報表"][reportName].Enable = UserAcl.Current["Student_Button_OfficialStudentRecordReport2010"].Executable; MotherForm.RibbonBarItems["學生", reportPath]["報表"]["成績相關報表"][reportName].Click += new EventHandler(button_student_OnClick); // 班級頁籤-->成績相關報表-->學籍表(97學年度入學適用) button_class = RoleAclSource.Instance["班級"]["報表"]; button_class.Add(new RibbonFeature("Class_Button_OfficialStudentRecordReport2010", "學籍表(97學年度入學適用)")); MotherForm.RibbonBarItems["班級", reportPath]["報表"]["成績相關報表"][reportName].Enable = UserAcl.Current["Class_Button_OfficialStudentRecordReport2010"].Executable; MotherForm.RibbonBarItems["班級", reportPath]["報表"]["成績相關報表"][reportName].Click += new EventHandler(button_class_OnClick); button_student = null; button_class = null; }
public void GetListContent_CheckSorting() { ICatalog catalog = new Catalog(); for (int i = 9; i >= 0; --i) { catalog.Add(new Content(ContentType.Book, new string[] { "TestTitle", "TestAuthor" + i, "432943" + i, "http://www.testingcatalog.com/" })); } IEnumerable<IContent> foundContent = catalog.GetListContent("TestTitle", 100); bool contentIsSorted = true; int currentIndex = 0; foreach (var item in foundContent) { if (!item.Author.EndsWith(currentIndex.ToString())) { contentIsSorted = false; break; } currentIndex++; } Assert.IsTrue(contentIsSorted); }
public void Add_TryToAddItemWithIncorectParamsCount() { string[] testBookContentParams = new string[] { "Intro C#" }; IContent testBookContent = new Content(ContentType.Book, testBookContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testBookContent); }
public void GetListContent_AddFiveItemsWithIndenticalTitlesAndTryToGetNegatiteCount() { string[] testBookContentParams = new string[] { "IndenticalTitle", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testBookContent = new Content(ContentType.Book, testBookContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testBookContent); currentCatalog.Add(testBookContent); string[] testMovieContentParams = new string[] { "IndenticalTitle", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" }; IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams); currentCatalog.Add(testMovieContent); string[] testApplicationContentParams = new string[] { "IndenticalTitle", "Mozilla", "16148072", "http://www.mozilla.org" }; IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams); currentCatalog.Add(testApplicationContent); string[] testSongContentParams = new string[] { "IndenticalTitle", "Metallica", "8771120", "http://goo.gl/dIkth7gs" }; IContent testSongContent = new Content(ContentType.Book, testSongContentParams); currentCatalog.Add(testSongContent); IEnumerable<IContent> currentContent = currentCatalog.GetListContent("IndenticalTitle", -1); int numberOfRenurnedResults = currentContent.Count(); Assert.AreEqual(0, numberOfRenurnedResults); }
public void UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLs() { string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); currentCatalog.Add(testContent); string oldURL = "http://www.introprogramming.info"; string newURL = "http://www.introprogramming.com"; currentCatalog.UpdateContent(oldURL, newURL); IEnumerable<IContent> currentContent = currentCatalog.GetListContent("Intro C#", 1); string currentContentNewURL = currentContent.First().URL; Assert.AreEqual(newURL, currentContentNewURL); }
public void UpdateContent_WithAllElementsMatching() { string oldUrl = "http://www.test.com/"; string newUrl = "http://www.modified.com/"; ICatalog catalog = new Catalog(); for (int i = 0; i < 10; ++i) { catalog.Add(new Content(ContentType.Music, new string[] { "TestTitle", "TestMusicAuthor", "3333", oldUrl })); } int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl); Assert.AreEqual(10, itemsUpdated); }
public void GetSingle() { Catalog catalog = new Catalog(); catalog.Add(new Content( ContentType.Application, "Java", "Pesho", 5, "http://pesho.com/" )); int expected = 1; int actual = catalog.GetListContent("Java", 1).Count(); Assert.AreEqual(expected, actual); }
public void UpdateCatalog_AddFiveItemsAndUpdateAll() { string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); currentCatalog.Add(testContent); string[] testMovieContentParams = new string[] { "IndenticalTitle", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://www.introprogramming.info" }; IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams); currentCatalog.Add(testMovieContent); string[] testApplicationContentParams = new string[] { "IndenticalTitle", "Mozilla", "16148072", "http://www.introprogramming.info" }; IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams); currentCatalog.Add(testApplicationContent); string[] testSongContentParams = new string[] { "DifferentTitle", "Metallica", "8771120", "http://www.introprogramming.info" }; IContent testSongContent = new Content(ContentType.Book, testSongContentParams); currentCatalog.Add(testSongContent); string oldURL = "http://www.introprogramming.info"; string newURL = "http://www.introprogramming.com"; int updatedItems = currentCatalog.UpdateContent(oldURL, newURL); Assert.AreEqual(5, updatedItems); }
public void UpdateContent_WithNoMatchingElemet() { ICatalog catalog = new Catalog(); catalog.Add(new Content(ContentType.Music, new string[] { "TestTitle", "TestMusicAuthor", "3333", @"http://www.test1.com/" })); int itemsUpdated = catalog.UpdateContent("http://www.test.com/", "http://www.modified.com/"); Assert.AreEqual(0, itemsUpdated); }
public void UpdateContent_WithSingleMatchingElement_ShouldReturn1() { string oldUrl = "http://www.test0.com/"; string newUrl = "http://www.modified.com/"; ICatalog catalog = new Catalog(); for (int i = 0; i < 10; ++i) { catalog.Add(new Content(ContentType.Music, new string[] { "TestTitle", "TestMusicAuthor", "3333", @"http://www.test" + i + ".com/" })); } int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl); Assert.AreEqual(1, itemsUpdated); }
public void UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLsCheckIsAllUpdated() { string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); currentCatalog.Add(testContent); string oldURL = "http://www.introprogramming.info"; string newURL = "http://www.introprogramming.com"; currentCatalog.UpdateContent(oldURL, newURL); IEnumerable<IContent> currentContent = currentCatalog.GetListContent("Intro C#", 1); bool isAllUpdated = true; foreach (IContent content in currentContent) { if (oldURL == content.URL) { isAllUpdated = false; break; } } Assert.IsTrue(isAllUpdated); }
public void UpdateContent_WithMultipleItemsmatch_TestIfUrlsAreUpdated() { string oldUrl = "http://www.test0.com/"; string newUrl = "http://www.modified.com/"; ICatalog catalog = new Catalog(); for (int i = 0; i < 10; ++i) { catalog.Add(new Content(ContentType.Music, new string[] { "TestTitle", "TestMusicAuthor", "3333", @"http://www.test" + (i % 2) + ".com/" })); } int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl); IEnumerable<IContent> updated = catalog.GetListContent("TestTitle", 1000); bool allAreUpdated = true; foreach (var item in updated) { if (item.Url == oldUrl) { allAreUpdated = false; break; } } Assert.IsTrue(allAreUpdated); }
public void UpdateCatalog_TryToUpdateMissingUrl() { string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }; IContent testContent = new Content(ContentType.Book, testContentParams); ICatalog currentCatalog = new Catalog(); currentCatalog.Add(testContent); string oldURL = "http://www.missingURL.info"; string newURL = "http://www.introprogramming.com"; int updatedItems = currentCatalog.UpdateContent(oldURL, newURL); Assert.AreEqual(0, updatedItems); }