public void AnniversaryTest2() { var anniversary = new Anniversary() { Day = 5, Month = 6 }; var aEvent = new Event() { ID = 1, Title = "Give Flowers to Wife", FrequencyTypeOptions = FrequencyTypeEnum.Yearly, Anniversary = anniversary }; var schedule = new Schedule(aEvent); Assert.IsFalse(schedule.IsOccurring(new DateTime(2009, 6, 4))); var range = new DateRange() { StartDateTime = new DateTime(2010, 1, 1), EndDateTime = new DateTime(2020, 12, 31) }; var occurrences = schedule.Occurrences(range).ToList(); Assert.IsTrue(occurrences.Count.Equals(11)); }
public void TestNextAnniversary() { List <Member> memberList = new List <Member>(); memberList.Add(new Member { firstName = "M", lastName = "K", active = true }); memberList.Add(new Member { firstName = "C", lastName = "W", birthday = DateTime.Now.AddYears(-20).AddDays(1), accession = DateTime.Now.AddYears(-15).AddDays(2) }); memberList.Add(new Member { firstName = "Max", lastName = "Mustermann", active = true, birthday = DateTime.Now.AddYears(-22).AddDays(3), accession = DateTime.Now.AddYears(-17).AddDays(42) }); int i = 0; foreach (Member member in memberList) { member.setID(i); ++i; } Anniversary an = new Anniversary(memberList); List <string> item1 = an.nextAnniversary().Item1; List <string> item2 = an.nextAnniversary().Item2; Assert.AreEqual(2, item1.Count()); Assert.AreEqual(2, item2.Count()); Assert.AreEqual("C W (2 Tage)", item1[0]); Assert.AreEqual("Max Mustermann (42 Tage)", item1[1]); Assert.AreEqual(DateTime.Now.AddYears(-15).AddDays(2).ToString("dd'.'MM'.'yyyy") + " (15 Jahre)", item2[0]); Assert.AreEqual(DateTime.Now.AddYears(-17).AddDays(42).ToString("dd'.'MM'.'yyyy") + " (17 Jahre)", item2[1]); }
protected override void OnNavigatedTo(NavigationEventArgs e) { string anniId = string.Empty; if (!NavigationContext.QueryString.TryGetValue("anniid", out anniId)) { throw new Exception("get anniId id error"); } if (anniId.Equals("-1")) { PageName.Text = "New Anniversary"; newInstance = true; curData = new Anniversary(); } else { PageName.Text = "Edit Anniversary"; newInstance = false; curData = db.Anniversaries.Single(anni => anni.AnniId == Int32.Parse(anniId)); InputName.Text = curData.Name; InputPeriod.Text = curData.Period.ToString(); } PageName.Text = "" + curData.AnniId; CheckSaveBtnAvailability(); base.OnNavigatedTo(e); }
private void ToggleSwitch_Unchecked(object sender, RoutedEventArgs e) { ToggleSwitch swth = sender as ToggleSwitch; Anniversary anni = swth.DataContext as Anniversary; swth.Foreground = this.Resources["PhoneForegroundBrush"] as System.Windows.Media.Brush; newAnniversaries.Remove(anni.AnniId); }
private void AnnivesariesContextMenuItex_Click(object sender, RoutedEventArgs e) { MenuItem menu = sender as MenuItem; Anniversary data = menu.DataContext as Anniversary; if (menu.Header.Equals("Edit")) { NavigationService.Navigate(new Uri("/View/EditAnniversaryPage.xaml?anniid=" + data.AnniId, UriKind.Relative)); } }
public void live() { for (int i = Age; i < 100; ++i) { if (i % 5 == 0) { Anniversary.Invoke(); } } }
public static void ReadEntries(string filePath, IOrganizer org) { StreamReader reader = new StreamReader(filePath); using (reader) { string[] entries = reader.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < entries.Length; i++) { entries[i] = entries[i].Replace("Type: ", ""); entries[i] = entries[i].Replace("Subject: ", ""); entries[i] = entries[i].Replace("Comments: ", ""); entries[i] = entries[i].Replace("Date: ", ""); entries[i] = entries[i].Replace("CreatedOn: ", ""); } for (int i = 0; i < entries.Length; i++) { switch (entries[i]) { case "Anniversary": Anniversary anniversary = new Anniversary(entries[i + 1], entries[i + 2], DateTime.Parse(entries[i + 3])); anniversary.CreatedOn = DateTime.Parse(entries[i + 4]); org.Add(anniversary); i += 4; break; case "Meeting": Meeting meeting = new Meeting(entries[i + 1], entries[i + 2], DateTime.Parse(entries[i + 3])); meeting.CreatedOn = DateTime.Parse(entries[i + 4]); org.Add(meeting); i += 4; break; case "ToDo": ToDo toDo = new ToDo(entries[i + 1], entries[i + 2], DateTime.Parse(entries[i + 3])); toDo.CreatedOn = DateTime.Parse(entries[i + 4]); org.Add(toDo); i += 4; break; case "Memo": Memo memo = new Memo(entries[i + 1], entries[i + 2]); memo.CreatedOn = DateTime.Parse(entries[i + 4]); org.Add(memo); i += 3; break; default: throw new InvalidDataException(); } } } }
private GameObject ConvertToNode(Anniversary anniversary) { string summary = anniversary.Summary; string person = anniversary.Person; GameObject newNode = Instantiate(this.NodePrefab); string month = this.Calender.targetDate.Month.ToString(); string day = this.Calender.targetDate.Day.ToString(); newNode.GetComponentInChildren <Text>().text = string.Format("{0}月{1}日\n{2}", month, day, summary); return(newNode); }
public void AnniversaryTest1() { var anniversary = new Anniversary() { Day = 1, Month = 8 }; var aEvent = new Event() { ID = 1, Title = "Daughter's Birthday", FrequencyTypeOptions = FrequencyTypeEnum.Yearly, Anniversary = anniversary }; var schedule = new Schedule(aEvent); Assert.IsTrue(schedule.IsOccurring(new DateTime(2008, 8, 1))); }
public void loadDataBase() { search = string.Empty; importedContent = this.db.content(); this.members = this.importedContent.Item1; this.exam = this.importedContent.Item2; this.seminar = this.importedContent.Item3; memberView = CollectionViewSource.GetDefaultView(members); group(); List <Member> memberCopy = new List <Member>(); foreach (Member member in members) { memberCopy.Add(member.Clone()); } this.an = new Anniversary(memberCopy); this.birthday = this.an.nextBirthday().Item1; this.birthdayTooltip = this.an.nextBirthday().Item2; this.anniversary = this.an.nextAnniversary().Item1; this.anniversaryTooltip = this.an.nextAnniversary().Item2; }
public void TestInitialize() { List <Member> memberList = new List <Member>(); memberList.Add(new Member { firstName = "M", lastName = "K", active = true }); memberList.Add(new Member { firstName = "C", lastName = "W", birthday = new DateTime(2000, 11, 1) }); memberList.Add(new Member { firstName = "Max", lastName = "Mustermann", active = true, birthday = new DateTime(1999, 4, 3), accession = new DateTime(2001, 12, 1) }); int i = 0; foreach (Member member in memberList) { member.setID(i); ++i; } Anniversary an = new Anniversary(memberList); }
public void Run() { this.comunicator.ClearScreen(); this.MyMenu.DisplayMainMenu(); while (true) { if (this.currentCommand != Command.None) { this.comunicator.ClearScreen(); this.MyMenu.DisplayMainMenu(); } this.currentCommand = Command.None; this.controller.GetCommand(); switch (this.currentCommand) { case Command.D1: // View this.comunicator.ClearScreen(); this.MyMenu.DisplayView(); this.organizer.Restart(); while (true) { Entry currentEntry; this.controller.GetCommand(); if (this.currentCommand != Command.None) { this.comunicator.ClearScreen(); this.MyMenu.DisplayView(); if (this.currentCommand == Command.LeftArow) { this.organizer.GetPrevious(); } else if (this.currentCommand == Command.RightArrow) { this.organizer.GetNext(); } else if (this.currentCommand == Command.Delete) { // delete if (this.organizer.GetCurrent() == null) { this.comunicator.DisplayMessage(new string[] { "No entry" }); this.currentCommand = Command.None; continue; } currentEntry = this.organizer.GetCurrent(); this.organizer.Remove(currentEntry); this.comunicator.DisplayMessage(new string[] { "->An entry has been deleted!, Moving to the the next entry!" }); } else if (this.currentCommand == Command.Esc) { break; } if (this.organizer.GetCurrent() == null) { this.comunicator.DisplayMessage(new string[] { "No More Entries" }); this.currentCommand = Command.None; continue; } currentEntry = this.organizer.GetCurrent(); // Display current Info this.comunicator.DisplayMessage(currentEntry.GetInformation()); this.currentCommand = Command.None; Thread.Sleep(25); } } break; case Command.D2: // Adding this.comunicator.ClearScreen(); this.MyMenu.DisplayAdd(); this.MyMenu.DisplayAddOptions(); while (true) { this.currentCommand = Command.None; this.controller.GetCommand(); if (this.currentCommand != Command.None) { if (this.currentCommand == Command.D1) { // Anniversary this.comunicator.ClearScreen(); this.comunicator.DisplayMessage(new string[] { "Enter Anniversary Info" }); this.comunicator.DisplayMessage(new string[] { "Entry Subject: " }); string subject = this.comunicator.ReadStringData(); this.comunicator.DisplayMessage(new string[] { "Comments: " }); string comment = this.comunicator.ReadStringData(); DateTime date = this.comunicator.ParseDate(); Anniversary newAnniversary = new Anniversary(subject, comment, date); this.organizer.Add(newAnniversary as Entry); this.comunicator.DisplayMessage(new string[] { "Anniversary Added Successfully! - Press Esc to Continue" }); } else if (this.currentCommand == Command.D2) { // Meeting this.comunicator.ClearScreen(); this.comunicator.DisplayMessage(new string[] { "Enter Meeting Info" }); this.comunicator.DisplayMessage(new string[] { "Entry Subject: " }); string subject = this.comunicator.ReadStringData(); this.comunicator.DisplayMessage(new string[] { "Comments: " }); string comment = this.comunicator.ReadStringData(); try { DateTime date = this.comunicator.ParseDate(); if (date < DateTime.Now) { throw new OutOfRange(DateTime.Now, "Date of Meeting cannot be old - Press Esc to Continue"); } else { Meeting newMeeting = new Meeting(subject, comment, date); this.organizer.Add(newMeeting as Entry); this.comunicator.DisplayMessage(new string[] { "Meeting Added Successfully! - Press Esc to Continue" }); } } catch (OutOfRange ex) { this.comunicator.DisplayMessage(new string[] { ex.Message }); } } else if (this.currentCommand == Command.D3) { // Memo this.comunicator.ClearScreen(); this.comunicator.DisplayMessage(new string[] { "Enter Memo Info" }); this.comunicator.DisplayMessage(new string[] { "Entry Subject: " }); string subject = this.comunicator.ReadStringData(); this.comunicator.DisplayMessage(new string[] { "Comment: " }); string comment = this.comunicator.ReadStringData(); Memo newMemo = new Memo(subject, comment); this.organizer.Add(newMemo as Entry); this.comunicator.DisplayMessage(new string[] { "Memo Added Successfully! - Press Esc to Continue" }); } if (this.currentCommand == Command.D4) { // ToDo this.comunicator.ClearScreen(); this.comunicator.DisplayMessage(new string[] { "Enter ToDo Info" }); this.comunicator.DisplayMessage(new string[] { "Entry Subject: " }); string subject = this.comunicator.ReadStringData(); this.comunicator.DisplayMessage(new string[] { "Comment: " }); string comment = this.comunicator.ReadStringData(); try { DateTime date = this.comunicator.ParseDate(); if (date < DateTime.Now) { throw new OutOfRange(DateTime.Now, "Date of ToDo cannot be old - Press Esc to Continue"); } else { ToDo newToDo = new ToDo(subject, comment, date); this.organizer.Add(newToDo as Entry); this.comunicator.DisplayMessage(new string[] { "ToDo Added Successfully! - Press Esc to Continue" }); } } catch (OutOfRange ex) { this.comunicator.DisplayMessage(new string[] { ex.Message }); } } else if (this.currentCommand == Command.Esc) { break; } } Thread.Sleep(100); } break; case Command.D3: // Alert Mode this.comunicator.ClearScreen(); int coutner = 101; while (true) { // Alert Mode this.controller.GetCommand(); if (this.currentCommand == Command.Esc) { break; } if (coutner >= 100) { this.controller.GetCommand(); this.comunicator.ClearScreen(); this.comunicator.DisplayMessage(new string[] { "Alert Mode Entered - press Esc to go to previous menu" }); this.organizer.Restart(); while (this.organizer.GetCurrent() != null) { Entry newEntry = this.organizer.GetCurrent(); if (newEntry.IsHot() == true && newEntry.IsObsolete() == false) { this.comunicator.DisplayMessage(new string[] { "\nEvent gone hot!" }); this.comunicator.DisplayMessage(newEntry.GetInformation()); } this.Organizer.GetNext(); } coutner = 0; } Thread.Sleep(150); coutner++; } break; case Command.Esc: TextFilesIO.PrintAll(@"../../entries.txt", this.organizer); return; } // this.currentCommand = Command.None; Thread.Sleep(50); } }
public void TestInitializeEmpty() { List <Member> memberList = new List <Member>(); Anniversary an = new Anniversary(memberList); }
public void TestInitializeNull() { List <Member> memberList = null; Anniversary an = new Anniversary(memberList); }