public void TestPersonCollectionAreEqual() { PersonCollection listA = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); PersonCollection listB = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); bool actual = (listA == listB); Assert.IsTrue(actual); }
public void TestPersonCollectionOfDifferentOrderWithSamePeopleAreEqual() { PersonCollection listA = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); PersonCollection listB = new PersonCollection(new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555"), new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555")); bool actual = (listA != listB); Assert.IsFalse(actual); }
public XMasPickList CreateChristmasPick(DateTime evaluationDate) { int MaxAttemptsBeforeGivingUp = 10; PersonCollection alreadyPicked = new PersonCollection(); XMasPickList thisYearPickList = new XMasPickList(evaluationDate); SortPickList(this.familyList, evaluationDate); for (int attempts = 1; attempts <= MaxAttemptsBeforeGivingUp; attempts++) { foreach (var subject in familyList) { PersonCollection availableToBePicked = CreatePossiblePickList(subject, alreadyPicked); if (availableToBePicked.Count == 0) { // Reset pick list creation info and try again. alreadyPicked = new PersonCollection(); thisYearPickList = new XMasPickList(evaluationDate); // throw new NotImplementedException("I have no idea how to handle this yet."); Console.WriteLine("{0} had no available people to pick, attempt: {1} Reset lists and try again.", subject, attempts); break; } if (availableToBePicked.Count > 1) { SortPickList(availableToBePicked, evaluationDate); int tmpIndex = indexGenerator.GenerateNumberBetweenZeroAnd(availableToBePicked.Count); Person toBuyPresentFor = availableToBePicked.GetAt((tmpIndex == 0) ? tmpIndex : (tmpIndex - 1)); alreadyPicked.Add(toBuyPresentFor); thisYearPickList.Add(new XMasPick(subject, toBuyPresentFor)); } else { Person toBuyPresentFor = availableToBePicked.GetAt(0); alreadyPicked.Add(toBuyPresentFor); thisYearPickList.Add(new XMasPick(subject, toBuyPresentFor)); } } Console.WriteLine("Verifing attempt: {0} ...", attempts); try { // Throws exceptions if a person is not recieving a present. foreach (Person person in familyList) { Person recipient = thisYearPickList.GetRecipientFor(person); } Console.WriteLine("Successfully created pick list in {0} attempts.", attempts); break; } catch (Exception err) { Console.WriteLine("Attempt {0} failed because {1}", attempts, err.ToString()); } } return thisYearPickList; }
public void TestChristmaPickServiceUsingTheSequentialNumberGeneratorWithOneRuleThatIsAlwaysPassingForOddChristmasYear() { PersonCollection pickList = new PersonCollection(); Person MaxG = new Person("Max", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555"); Person CharlotteG = new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555"); Person MadelineG = new Person("Madeline", "Gehred", new DateTime(1988, 4, 15), "14111111-2222-3333-4444-555555555555"); Person CecilaG = new Person("Cecila", "Gehred", new DateTime(1990, 6, 21), "15111111-2222-3333-4444-555555555555"); pickList.Add(MaxG); pickList.Add(CharlotteG); pickList.Add(MadelineG); pickList.Add(CecilaG); IPickListService testObj = new PickListServiceAdvanced(new SequentialNumberGenerator(pickList.Count), new TestRuleProvider(), pickList); XMasPickList actual = testObj.CreateChristmasPick(new DateTime(2007, 12, 25)); XMasPick expectedFirstPick = new XMasPick(CharlotteG, MaxG); Assert.IsTrue((expectedFirstPick == actual[0])); XMasPick expectedSecondPick = new XMasPick(MaxG, CecilaG); Assert.IsTrue(expectedSecondPick == actual[1]); XMasPick expectedThirdPick = new XMasPick(CecilaG, MadelineG); Assert.IsTrue(expectedThirdPick == actual[2]); XMasPick expectedFourthPick = new XMasPick(MadelineG, CharlotteG); Assert.IsTrue(expectedFourthPick == actual[3]); }
public IDictionary<Person, ExchangeCheckSum> PickListToValidateWithPeopleList(PersonCollection personList, XMasPickList pickList) { IDictionary<Person, ExchangeCheckSum> checkList = new Dictionary<Person, ExchangeCheckSum>(); foreach (Person person in personList) { checkList.Add(person, new ExchangeCheckSum()); } foreach (XMasPick pick in pickList) { if (checkList.ContainsKey(pick.Recipient)) { checkList[pick.Recipient].updatePresentsIn(); } else { throw new Exception(string.Format("The recipient {0} is not found in adult list", pick.Recipient)); } if (checkList.ContainsKey(pick.Subject)) { checkList[pick.Subject].updatePresentsOut(); } else { throw new Exception(string.Format("The subject {0} is not found in adult list", pick.Subject)); } } return checkList; }
public void after_Add_canUndo_is_true() { IChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection( svc ); p.Add( new Person( svc, false ) ); svc.CanUndo.Should().Be.True(); }
static void showPeople(PersonCollection persons) { foreach (Person person in persons) { Console.WriteLine(person); } Console.WriteLine(); }
public void after_mutual_exclusive_actions_service_CanUndo() { IChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection( svc ); p.Add( new Person( svc, false ) ); p.RemoveAt( 0 ); Assert.IsTrue( svc.CanUndo ); }
public void TestPersonCollectionDeserialization() { PersonCollection expected = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); PersonCollection actual = null; byte[] serializedData = ConvertStringToByteArray("<?xml version=\"1.0\"?>\r\n<PersonCollection>\r\n <Person firstname=\"Bob\" lastname=\"Gehred\" birthday=\"7/27/1972\" id=\"21111111-2222-3333-4444-555555555555\" />\r\n <Person firstname=\"Angie\" lastname=\"Gehred\" birthday=\"9/26/1971\" id=\"11111111-2222-3333-4444-555555555555\" />\r\n</PersonCollection>"); Stream testData = new MemoryStream(serializedData); XmlSerializer xml = new XmlSerializer(typeof(PersonCollection)); actual = (PersonCollection)xml.Deserialize(testData); Assert.AreEqual(expected, actual); }
public void after_Add_getChangeSet_contains_change() { IChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection( svc ); p.Add( new Person( svc, false ) ); p.Add( new Person( svc, false ) ); IChangeSet cSet = svc.GetChangeSet(); cSet.Count.Should().Be.EqualTo( 2 ); }
public void after_Undo_collection_is_rolledback() { Int32 expected = 0; IChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection( svc ); p.Add( new Person( svc, false ) ); svc.Undo(); p.Count.Should().Be.EqualTo( expected ); }
public PersonController() { personCollection = new PersonCollection(); if (personCollection.PersonsCollection != null) { personObjects = personCollection.PersonsCollection; } else { personObjects = new List<Person>(); } }
private static PersonCollection Make(string prefix, int count) { PersonCollection persons = new PersonCollection(); for (int index = 1; index <= count; ++index) { persons.Add(new Person { Name = string.Format("{0}-{1}", prefix, index), Age = index * 10, SSN = (uint)index }); } return persons; }
public void after_add_GetEntityState_is_Changed() { EntityTrackingStates expected = EntityTrackingStates.HasBackwardChanges; ChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection( svc ); p.Add( new Person( svc, false ) ); p.Add( new Person( svc, false ) ); EntityTrackingStates actual = svc.GetEntityState( p ); actual.Should().Be.EqualTo( expected ); }
public Family CreateMilwaukeeGehredFamily() { Person AngieG = new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555"); Person BobG = new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"); Person MaxG = new Person("Max", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555"); Person CharlotteG = new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555"); PersonCollection parents = new PersonCollection(AngieG, BobG); PersonCollection kids = new PersonCollection(); kids.Add(MaxG); kids.Add(CharlotteG); return new Family("Brew City Gehreds", parents, kids); }
public void AddPerson_DuplicatedEmail_ShouldWorkCorrectly() { // Arrange var persons = new PersonCollection(); // Act var isAddedFirst = persons.AddPerson("*****@*****.**", "Peter", 18, "Sofia"); var isAddedSecond = persons.AddPerson("*****@*****.**", "Maria", 24, "Plovdiv"); // Assert Assert.IsTrue(isAddedFirst); Assert.IsFalse(isAddedSecond); Assert.AreEqual(1, persons.Count); }
public static void TestStringIndexer() { Console.WriteLine("***** Fun with Indexers *****\n"); PersonCollection myPeople = new PersonCollection(); myPeople["Homer"] = new Person("Homer", "Simpson", 40); myPeople["Marge"] = new Person("Marge", "Simpson", 38); // Get "Homer" and print data. Person homer = myPeople["Homer"]; Console.WriteLine(homer.ToString()); Console.ReadLine(); }
private void GroupByProperty(PropertyGroupDescription groupOption, GroupStyle grpStyle) { PersonCollection persons = (PersonCollection)FindResource("persons"); ICollectionView view = CollectionViewSource.GetDefaultView(persons); if (view.GroupDescriptions.Count == 0) { view.GroupDescriptions.Add(groupOption); lbxPersons.GroupStyle.Add(grpStyle); } else { view.GroupDescriptions.Clear(); lbxPersons.GroupStyle.Clear(); } }
public void DeletePerson_ShouldWorkCorrectly() { // Arrange var persons = new PersonCollection(); persons.AddPerson("*****@*****.**", "Peter", 28, "Plovdiv"); // Act var isDeletedExisting = persons.DeletePerson("*****@*****.**"); var isDeletedNonExisting = persons.DeletePerson("*****@*****.**"); // Assert Assert.IsTrue(isDeletedExisting); Assert.IsFalse(isDeletedNonExisting); Assert.AreEqual(0, persons.Count); }
public void TestPerformance_FindPerson() { // Arrange var persons = new PersonCollection(); AddPersons(5000, persons); // Act for (int i = 0; i < 100000; i++) { var existingPerson = persons.FindPerson("*****@*****.**"); Assert.IsNotNull(existingPerson); var nonExistingPerson = persons.FindPerson("non-existing email"); Assert.IsNull(nonExistingPerson); } }
public void SortPersonCollectionWithSpecifiedComparerSortsCorrectly() { var personCollection = new PersonCollection(); personCollection.Add(new Person { FirstName = "John", LastName = "Doe" }); personCollection.Add(new Person { FirstName = "Jane", LastName = "Doe" }); personCollection.Sort(new PersonComparer()); Assert.Equal("Jane Doe", personCollection[0].FullName); Assert.Equal("John Doe", personCollection[1].FullName); }
public void Join_PatientIndexTable_ThreeServers() { /* * Server1 Server 2 Server 3 * _____________ _________ * |Biochemistry| → (successfully caches joinable bit) | Cache | * * ↘ join ↘ (should crash) * _____________________ * | Hospital Admissions| * */ var server1 = GetCleanedServer(DatabaseType.MySql); var server2 = GetCleanedServer(DatabaseType.MicrosoftSQLServer); var server3 = GetCleanedServer(DatabaseType.Oracle); ExternalDatabaseServer cache = CreateCache(server3); var r = new Random(500); var people = new PersonCollection(); people.GeneratePeople(5000, r); var cic = new CohortIdentificationConfiguration(CatalogueRepository, "cic"); var joinable = SetupPatientIndexTable(server1, people, r, cic); cic.CreateRootContainerIfNotExists(); cic.QueryCachingServer_ID = cache?.ID; cic.SaveToDatabase(); var hospitalAdmissions = SetupPatientIndexTableUser(server2, people, r, cic, joinable); cic.RootCohortAggregateContainer.AddChild(hospitalAdmissions, 0); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 50000); runner.Run(new CancellationToken()); var hospitalAdmissionsTask = compiler.Tasks.Keys.OfType <AggregationTask>().Single(t => t.Aggregate.Equals(hospitalAdmissions)); Assert.AreEqual(CompilationState.Crashed, hospitalAdmissionsTask.State); StringAssert.Contains("is not fully cached and CacheUsageDecision is MustUse", hospitalAdmissionsTask.CrashMessage.ToString()); }
public MainWindowViewModel(Mediator mediator) { this.mediator = mediator; DeleteCommand = new RelayCommand(DeleteExecute, CanDelete); this.PropertyChanged += MainWindowViewModel_PropertyChanged; PersonList = PersonCollection.GetAllPersons(); PersonListView = new ListCollectionView(PersonList); PersonListView.Filter = PersonFiler; CurrentPerson = new Person(); mediator.Register("PersonChange", PersonChanged); }
void Command_Save_Click() { // create a new instance of Model_Person in our collection PersonCollection.Add(new Model_Person() { FirstName = PersonEntry.FirstName, LastName = PersonEntry.LastName }); // and clear the fields PersonEntry.FirstName = null; PersonEntry.LastName = null; // then hide the view Command_CloseAddView.Execute(null); }
public void SavePosting(string userID, bool findPossibleMatch) { if (findPossibleMatch && _personID == -1 && _email.Trim() != string.Empty) { // Attempt to find person based on first name, last name, and email address PersonCollection possibleMatches = new PersonCollection(); possibleMatches.LoadByName(_firstName, _lastName); foreach (Person person in possibleMatches) { foreach (PersonEmail personEmail in person.Emails) { if (personEmail.Email.Trim().ToLower() == _email.Trim().ToLower()) { _personID = person.PersonID; break; } } } } _applicantID = new JobApplicantData().SaveJobApplicant( ApplicantID, Guid, Person.PersonID, JobPosting.JobPostingID, FirstName, LastName, Email, HowHeard, HowLongChristian, Class100, Class100Date, ChurchMember, NeighborhoodGroup, Serving, ServingMinistry, Baptized, Tithing, Experience, LedToApply, Coverletter, Resume.BlobID, RejectionNoticeSent, ReviewedByHR, userID); }
public override bool FindMatches(PersonCollection list, PersonMatchPairCollection pairs) { for (int firstIndex = 0; firstIndex < list.Count - 1; firstIndex += 1) { for (int secondIndex = firstIndex + 1; secondIndex < list.Count; secondIndex += 1) { if (list[firstIndex].FirstName == list[secondIndex].FirstName && list[firstIndex].LastName == list[secondIndex].LastName && list[firstIndex].SocialSecurityNumber == list[secondIndex].SocialSecurityNumber) { pairs.Add(Tuple.Create(list[firstIndex], list[secondIndex])); } } } return(pairs.Count > 0 ? true : false); }
public void _0003_Minden_Elem_Kivágása_Bellesztése() { var form = new SingleGridForm(); var dgv = form.GridView; var persons = new PersonCollection() { new PersonItem("Homer", "Simpson", 40), new PersonItem("Bart", "Simpson", 10), new PersonItem("Lisa", "Simpson", 13), new PersonItem("Marge", "Simpson", 10), }; dgv.DataSource = persons; dgv.ContextMenuStrip.Items.AddRange( new ToolStripItem[] { new CopyRowCommand(dgv, persons), new PasteRowsCommand(dgv, persons), new CutRowsCommand(dgv, persons), }); var menu = form.dataGridView1.ContextMenuStrip; for (int i = 0; i < dgv.Rows.Count; i++) { dgv.Rows[i].Selected = true; } var command = menu.Items.Cast <ToolStripItem>().FirstOrDefault(n => n.Text == @"Cut"); if (command != null) { command.PerformClick(); } Assert.AreEqual(0, persons.Count); command = menu.Items.Cast <ToolStripItem>().FirstOrDefault(n => n.Text == @"Paste"); if (command != null) { command.PerformClick(); } Assert.AreEqual(4, persons.Count); }
/// <summary> /// Save the information about a given peer. In a VoIP PBX system a peer is a physical /// device. A person may have multiple peers associated with him/her. For example I /// have a physical desk phone (first peer), a VoIP client on my iPhone (second peer). /// This method has been written on the assumption that I only care about my primary /// (desk phone) peer. We name our SIP peers after the extension, so my extension of /// 268 has a peer defined as "268". /// </summary> /// <param name="organizationId">The organization we are currently working in.</param> /// <param name="extensionRules">A collection of Lookups to use in matching this peer to a person.</param> /// <param name="objectName">The name of this peer object.</param> /// <param name="acl">Not a clue.</param> /// <param name="dynamic">If this is a dynamic (i.e. DHCP) peer.</param> /// <param name="natSupport">Does the peer support NAT?</param> /// <param name="ip">IP address of the peer.</param> /// <param name="type">The type of peer, e.g. SIP or IAX2.</param> private void SavePeer(int organizationId, LookupCollection extensionRules, string objectName, bool acl, bool dynamic, bool natSupport, string ip, string type) { string internalNumber = objectName; // // Match this peer to a extension and build internalNumber // to be the full phone number to reach this peer. // foreach (Lookup rule in extensionRules) { if (Regex.Match(objectName, rule.Qualifier).Success) { if (rule.Qualifier3 != string.Empty) { internalNumber = rule.Qualifier3.Replace("##orig##", objectName); } } } // // Find a person who has this exact phone number. If more than one person // is found, the first match is used. // PersonCollection peerPersons = new PersonCollection(); peerPersons.LoadByPhone(internalNumber); if (peerPersons.Count > 0) { // // Save the new Phone Peer object, which associates a physical phone to a person. // Arena.Phone.Peer peer = new Arena.Phone.Peer(objectName); peer.PersonId = peerPersons[0].PersonID; peer.Acl = acl; peer.Dynamic = dynamic; peer.NatSupport = natSupport; peer.Ip = ip; peer.ObjectName = objectName; peer.Type = type; peer.OrganizationId = organizationId; peer.InternalNumber = internalNumber; peer.LastAuditId = _sessionGuid; peer.Save("voipManager"); } }
public void ChangeTracking_EntityCollectionTracking() { var pc = new PersonCollection(); pc.TrackChanges(); Assert.IsTrue(pc.IsChangeTracking); var p = new Person { FirstName = "Jenny" }; Assert.IsFalse(p.IsChangeTracking); // Adding item will not pick up changes made prior to TrackChanges. pc.Add(p); Assert.IsTrue(pc.IsChanged); Assert.IsTrue(p.IsChangeTracking); Assert.IsTrue(p.IsChanged); Assert.AreEqual(new System.Collections.Specialized.StringCollection(), p.ChangeTracking); // Accept changes so no longer tracking anything. pc.AcceptChanges(); Assert.IsFalse(pc.IsChangeTracking); Assert.IsFalse(pc.IsChanged); Assert.IsFalse(p.IsChangeTracking); Assert.IsFalse(p.IsChanged); // Track changes again updating only the person name - changes should bubble. pc.TrackChanges(); p.FirstName = "Jennifer"; Assert.IsTrue(pc.IsChanged); Assert.IsTrue(p.IsChanged); Assert.AreEqual(new System.Collections.Specialized.StringCollection { "FirstName" }, p.ChangeTracking); // Remove item from collection, changes should no longer bubble. pc.AcceptChanges(); pc.Remove(p); pc.AcceptChanges(); p.FirstName = "Jen"; Assert.IsFalse(pc.IsChanged); Assert.IsTrue(p.IsChanged); Assert.IsFalse(p.IsChangeTracking); }
/// <summary> /// Setups this instance. /// </summary> /// TODO Edit XML Comment Template for Setup public override void Setup() { base.Setup(); BenchmarkDotNet.Loggers.ConsoleLogger.Default.WriteLine(BenchmarkDotNet.Loggers.LogKind.Info, $"Collection Count={this.CollectionCount}."); this.personFixedCollection = new PersonCollection <PersonFixed>(); this.personFixedCollection.AddRange(RandomData.GeneratePersonCollection <PersonFixed>(this.CollectionCount)); this.personProperCollection = new PersonCollection <PersonProper>(); this.personProperCollection.AddRange(RandomData.GeneratePersonCollection <PersonProper>(this.CollectionCount)); this.personProperDictionary = this.personProperCollection.ToDictionary(p => p.Id); this.testEmail = this.personProperCollection[RandomData.GenerateInteger(0, this.CollectionCount - 1)].Email; this.sortablePersonProperCollection = new PersonCollection <PersonProper>(this.personProperCollection); }
public static IEnumerable <FileInfo> GenerateImageFiles(this DicomDataGenerator g, int numberOfImages, Random r) { var p = new PersonCollection(); p.GeneratePeople(5000, r); if (g.OutputDir.Exists) { g.OutputDir.Delete(true); } var inventory = new FileInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "inventory.csv")); Path.Combine(TestContext.CurrentContext.WorkDirectory, "inventory.csv"); g.MaximumImages = numberOfImages; g.GenerateTestDataFile(p, inventory, numberOfImages); return(g.OutputDir.GetFiles("*.dcm", SearchOption.AllDirectories)); }
public void TestPerformance_FindPersonsByEmailDomain() { // Arrange var persons = new PersonCollection(); AddPersons(5000, persons); // Act for (int i = 0; i < 10000; i++) { var existingPersons = persons.FindPersons("gmail1.com").ToList(); Assert.AreEqual(50, existingPersons.Count); var notExistingPersons = persons.FindPersons("non-existing email").ToList(); Assert.AreEqual(0, notExistingPersons.Count); } }
public static PersonCollection GetPersonsByCompanyID(Int64 CompanyID) { PersonCollection c = new PersonCollection(); DataTable dt = Execute.FillDataTable(StoredProcedures.GetPersonsByCompanyID, new System.Data.SqlClient.SqlParameter("CompanyID", CompanyID)); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { Person o = new Person(); LoadPersonByReader(row, o); c.Add(o); } } return(c); }
public override bool Read(PersonCollection list, string filename) { StreamReader reader = new StreamReader(filename); List <Person> fileData = XmlSerializer.Deserialize(reader.BaseStream) as List <Person>; if (fileData != null) { foreach (Person person in fileData) { list.Add(person); } } else { return(false); } return(true); }
public void TestPerformance_FindPersonsByAgeRange() { // Arrange var persons = new PersonCollection(); AddPersons(5000, persons); // Act for (int i = 0; i < 2000; i++) { var existingPersons = persons.FindPersons(20, 21).ToList(); Assert.AreEqual(100, existingPersons.Count); var notExistingPersons = persons.FindPersons(500, 600).ToList(); Assert.AreEqual(0, notExistingPersons.Count); } }
public void Save() { try { //set a new id //CurrentPerson.Id = new IDmanager().ID; PersonCollection.Add(CurrentPerson); PersonService.Add(CurrentPerson); Message = "Person saved to db"; } catch (Exception e) { PersonCollection.Remove(CurrentPerson); Message = e.Message; } }
public void TestPerformance_FindPersonsByNameAndTown() { // Arrange var persons = new PersonCollection(); AddPersons(5000, persons); // Act for (int i = 0; i < 10000; i++) { var existingPersons = persons.FindPersons("Pesho1", "Sofia1").ToList(); Assert.AreEqual(50, existingPersons.Count); var notExistingPersons = persons.FindPersons("Pesho1", "Sofia5").ToList(); Assert.AreEqual(0, notExistingPersons.Count); } }
public void Join_PatientIndexTable_NotOnCacheServer() { /* * Server1 Server 2 * _____________ _________ * |Biochemistry| → | Cache | (cache must first be populated) * * ↘ join ↘ (must use cache) * _____________________ * | Hospital Admissions| * */ var server1 = GetCleanedServer(DatabaseType.MySql); var server2 = GetCleanedServer(DatabaseType.MicrosoftSQLServer); ExternalDatabaseServer cache = CreateCache(server2); var r = new Random(500); var people = new PersonCollection(); people.GeneratePeople(5000, r); var cic = new CohortIdentificationConfiguration(CatalogueRepository, "cic"); var joinable = SetupPatientIndexTable(server1, people, r, cic); cic.CreateRootContainerIfNotExists(); cic.QueryCachingServer_ID = cache?.ID; cic.SaveToDatabase(); var hospitalAdmissions = SetupPatientIndexTableUser(server2, people, r, cic, joinable); cic.RootCohortAggregateContainer.AddChild(hospitalAdmissions, 0); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 50000); runner.Run(new CancellationToken()); AssertNoErrors(compiler); Assert.IsTrue(compiler.Tasks.Any(t => t.Key.GetCachedQueryUseCount().Equals("1/1")), "Expected cache to be used only for the final UNION"); }
private void btnSubmit_Click(object sender, EventArgs e) { if (!this.Page.IsValid) { this.Page.FindControl("valSummary").Visible = true; return; } if (!(this.tbEmail.Text.Trim().ToLower() != this.iEmail.Value)) { this.CreateAccount(); return; } PersonCollection personCollection = new PersonCollection(); personCollection.LoadByEmail(this.tbEmail.Text.Trim()); if (personCollection.Count <= 0) { this.CreateAccount(); return; } this.phExistingAccounts.Controls.Clear(); StringBuilder stringBuilder = new StringBuilder(); foreach (Person current in personCollection) { using (List <Arena.Security.Login> .Enumerator enumerator2 = current.Logins.GetEnumerator()) { if (enumerator2.MoveNext()) { Arena.Security.Login arg_A5_0 = enumerator2.Current; stringBuilder.AppendFormat("{0} - <a href='default.aspx?page={1}&email={2}'>Send Info</a><br>", current.FullName, this.RequestInfoPageIDSetting, this.tbEmail.Text.Trim()); } } } if (stringBuilder.Length > 0) { this.phExistingAccounts.Controls.Add(new LiteralControl(stringBuilder.ToString())); this.pnlMessage.Visible = true; this.pnlEmailExists.Visible = true; this.iEmail.Value = this.tbEmail.Text.Trim().ToLower(); return; } this.CreateAccount(); }
public void Test_CsvOption() { var r = new Random(500); var outputDir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "TestCsv")); outputDir.Create(); var people = new PersonCollection(); people.GeneratePeople(100, r); using (var generator = new DicomDataGenerator(r, outputDir, "CT")) { generator.Csv = true; generator.NoPixels = true; generator.MaximumImages = 500; generator.GenerateTestDataFile(people, new FileInfo(Path.Combine(outputDir.FullName, "index.csv")), 500); } //3 csv files + index.csv (the default one Assert.AreEqual(4, outputDir.GetFiles().Length); foreach (FileInfo f in outputDir.GetFiles()) { using (var reader = new CsvReader(new StreamReader(f.FullName), CultureInfo.CurrentCulture)) { int rowcount = 0; //confirms that the CSV is intact (no dodgy commas, unquoted newlines etc) while (reader.Read()) { rowcount++; } //should be 1 row per image + 1 for header if (f.Name == DicomDataGenerator.ImageCsvFilename) { Assert.AreEqual(501, rowcount); } } } }
private void RunAsPatientIndexTable(AggregateConfiguration ac, CachedAggregateConfigurationResultsManager cache, CancellationToken token) { using DataTable dt = new DataTable(); dt.Columns.Add("chi", typeof(string)); dt.Columns.Add("dateOfBirth", typeof(DateTime)); dt.Columns.Add("dateOfDeath", typeof(DateTime)); // generate a list of random chis + date of birth/death var pc = new PersonCollection(); pc.GeneratePeople(GetNumberToGenerate(ac), new Random()); foreach (var p in pc.People) { dt.Rows.Add(p.CHI, p.DateOfBirth, p.DateOfDeath ?? (object)DBNull.Value); } SubmitPatientIndexTable(dt, ac, cache, true); }
public void ContainsAnyTest() { var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToList(); var emptyCollection = new PersonCollection <PersonProper>(); var coordinate = RandomData.GenerateCoordinate <Coordinate>(); //Test params Assert.IsFalse(collection.ContainsAny()); Assert.IsFalse(collection.ToArray().ContainsAny()); Assert.IsFalse(emptyCollection.ContainsAny()); Assert.IsFalse(collection.ContainsAny(coordinate)); collection.Add(coordinate); Assert.IsTrue(collection.ContainsAny(coordinate)); Assert.IsTrue(collection.ToArray().ContainsAny(coordinate)); }
public DataTemplate() { InitializeComponent(); // initialize peoples PersonCollection persons = new PersonCollection(); for (int index = 1; index <= 10; ++index) { persons.Add(new Person { Name = string.Format("Person{0}", index), SSN = (uint)index, Age = index * 10 }); } m_personsView = CollectionViewSource.GetDefaultView(persons); gridTeam.DataContext = m_personsView; }
public void CreateAdultListFromFamilyTree() { FamilyTree testFamilyTree = CreateFamilyTree(); DateTime christmas2008 = new DateTime(2008, 12, 25); PersonCollection actualAdultList = testFamilyTree.CreateChristmasAdultList(christmas2008); PersonCollection expectedAdultList = new PersonCollection(); Person AnnG = new Person("Ann", "Gehred", new DateTime(1962, 9, 26), "12111111-2222-3333-4444-555555555555"); Person JohnG = new Person("John", "Gehred", new DateTime(1962, 2, 13), "13111111-2222-3333-4444-555555555555"); Person AngieG = new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555"); Person BobG = new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"); expectedAdultList.Add(AnnG); expectedAdultList.Add(JohnG); expectedAdultList.Add(AngieG); expectedAdultList.Add(BobG); Assert.IsTrue((expectedAdultList == actualAdultList)); }
protected void lnkDeleteSelected_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Form["chkSelectedItems"])) { string[] selectedItems = Request.Form["chkSelectedItems"].Split(','); for (int i = 0; i < selectedItems.Length; i++) { try { Person.Delete(int.Parse(selectedItems[i])); } catch { } } gridPeople.DataSource = PersonCollection.GetAll(); gridPeople.DataBind(); } }
public void FindPersonsByAgeRangeAndTown_ShouldReturnMatchingPersons() { // Arrange var persons = new PersonCollection(); persons.AddPerson("*****@*****.**", "Pesho", 28, "Plovdiv"); persons.AddPerson("*****@*****.**", "Kiril", 22, "Sofia"); persons.AddPerson("*****@*****.**", "Kiril", 22, "Plovdiv"); persons.AddPerson("*****@*****.**", "Pesho", 21, "Plovdiv"); persons.AddPerson("*****@*****.**", "Anna", 19, "Bourgas"); persons.AddPerson("*****@*****.**", "Anna", 17, "Bourgas"); persons.AddPerson("*****@*****.**", "Pesho", 21, "Plovdiv"); persons.AddPerson("*****@*****.**", "Asen", 21, "Rousse"); persons.AddPerson("*****@*****.**", "Asen", 21, "Plovdiv"); // Act var personsAgedFrom21to22Plovdiv = persons.FindPersons(21, 22, "Plovdiv"); var personsAgedFrom10to11Sofia = persons.FindPersons(10, 11, "Sofia"); var personsAged21Plovdiv = persons.FindPersons(21, 21, "Plovdiv"); var personsAged19Bourgas = persons.FindPersons(19, 19, "Bourgas"); var personsAgedFrom0to1000Plovdiv = persons.FindPersons(0, 1000, "Plovdiv"); var personsAgedFrom0to1000NewYork = persons.FindPersons(0, 1000, "New York"); // Assert CollectionAssert.AreEqual( new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }, personsAgedFrom21to22Plovdiv.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { }, personsAgedFrom10to11Sofia.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**" }, personsAged21Plovdiv.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { "*****@*****.**" }, personsAged19Bourgas.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }, personsAgedFrom0to1000Plovdiv.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { }, personsAgedFrom0to1000NewYork.Select(p => p.Email).ToList()); }
static void Main(string[] args) { PersonCollection people = new PersonCollection(); people.Add(new Person { FirstName = "Larry", LastName = "Fine" }); people.Add(new Person { FirstName = "Moe", LastName = "Howard" }); people.Add(new Person { FirstName = "Curly", LastName = "Howard" }); showPeople(people); people.RemoveAt(1); showPeople(people); Person person = people[0]; people.Remove(person); showPeople(people); }
public void SortPersonCollectionByYoungestToOldest() { PersonCollection testList = new PersonCollection(); Person MaxG = new Person("Max", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555"); Person CharlotteG = new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555"); Person MadelineG = new Person("Madeline", "Gehred", new DateTime(1988, 4, 15), "14111111-2222-3333-4444-555555555555"); Person CecilaG = new Person("Cecila", "Gehred", new DateTime(1990, 6, 21), "15111111-2222-3333-4444-555555555555"); testList.Add(MaxG); testList.Add(CharlotteG); testList.Add(MadelineG); testList.Add(CecilaG); testList.Sort(new PersonComparerByAgeYoungestToOldest()); Assert.IsTrue((testList.GetAt(3) == MadelineG)); Assert.IsTrue((testList.GetAt(2) == CecilaG)); Assert.IsTrue((testList.GetAt(1) == MaxG)); Assert.IsTrue((testList.GetAt(0) == CharlotteG)); }
public void IndexerTest() { var person = new Person { FirstName = "John", LastName = "Doe" }; var people = new PersonCollection(); people.Add(person); var foo = people[0]; Assert.AreSame(person, foo); var bar = people["John", "Doe"]; Assert.AreEqual(bar.Count(), 1); }
public void changeTrackingService_using_beginAtomicOperation_should_set_is_changed_only_on_operation_completed() { var target = new ChangeTrackingService(); var person = new Person( target ); var list = new PersonCollection( target ); using( var actual = target.BeginAtomicOperation() ) { person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; target.IsChanged.Should().Be.False(); actual.Complete(); } target.IsChanged.Should().Be.True(); }
public void changeTrackingService_using_beginAtomicOperation_should_fully_rollback_on_single_undo() { var target = new ChangeTrackingService(); var person = new Person( target ); var list = new PersonCollection( target ); using( var actual = target.BeginAtomicOperation() ) { person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; actual.Complete(); } target.Undo(); list.Count.Should().Be.EqualTo( 0 ); person.Name.Should().Be.EqualTo( String.Empty ); }
public FamilyTree GetFamilies() { FamilyTree christmasPickList = new FamilyTree(); PersonCollection milwaukeeGehredParents = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); PersonCollection milwaukeeGehredKids = new PersonCollection(); milwaukeeGehredKids.Add(new Person("Maxwell", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555")); milwaukeeGehredKids.Add(new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555")); Family milwaukeeGehreds = new Family("milwaukeeGehreds", milwaukeeGehredParents, milwaukeeGehredKids); PersonCollection tosaGehredParents = new PersonCollection(new Person("John", "Gehred", new DateTime(1961, 2, 16), "13111111-2222-3333-4444-555555555555"), new Person("Ann", "Gehred", new DateTime(1961, 5, 17), "12111111-2222-3333-4444-555555555555")); PersonCollection tosaGehredKids = new PersonCollection(); tosaGehredKids.Add(new Person("Madeline", "Gehred", new DateTime(1994, 4, 12), "14111111-2222-3333-4444-555555555555")); tosaGehredKids.Add(new Person("Cecila", "Gehred", new DateTime(1997, 10, 12), "15111111-2222-3333-4444-555555555555")); Family tosaGehreds = new Family("tosaGehreds", tosaGehredParents, tosaGehredKids); christmasPickList.Add(milwaukeeGehreds); christmasPickList.Add(tosaGehreds); return christmasPickList; }
static void Main(string[] args) { /*Now that you have a strongly typed PersonCollection class, you can use it in your code! Let's create an instance of PersonsCollection and add two Person objects. */ PersonCollection persons = new PersonCollection(); persons.Add(new Person() { Id = 1, FirstName = "Luis Felipe", LastName = "Oliveira" }); persons.Add(new Person() { Id = 2, FirstName = "Fulaninho", LastName = "da Silva" }); /*Now we can iterave over persons collection using a foreach statement*/ foreach (Person person in persons){ Console.WriteLine(string.Format("Id {0}, First Name {1}, Last Name {2}", person.Id.ToString(), person.FirstName, person.LastName)); } }
public void changeTrackingService_using_beginAtomicOperation_redo_should_reapply_all_changes_with_one_pass() { var target = new ChangeTrackingService(); var person = new Person( target ); var list = new PersonCollection( target ); using( var actual = target.BeginAtomicOperation() ) { person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; actual.Complete(); } target.Undo(); target.Redo(); list.Count.Should().Be.EqualTo( 1 ); person.Name.Should().Be.EqualTo( "Mauro Servienti" ); }
public void changeTrackingService_using_beginAtomicOperation_hasTransientEntities_should_return_true_even_for_entities_created_in_the_atomic_operation() { var target = new ChangeTrackingService(); var list = new PersonCollection( target ); var person = new Person( target, false ); using( var op = target.BeginAtomicOperation() ) { target.RegisterTransient( person ); person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; op.Complete(); } var actual = target.HasTransientEntities; actual.Should().Be.True(); }
public void changeTrackingService_using_beginAtomicOperation_getEntities_should_return_all_transient_entities() { var target = new ChangeTrackingService(); var list = new PersonCollection( target ); var person = new Person( target, false ); using( var op = target.BeginAtomicOperation() ) { target.RegisterTransient( person ); person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; op.Complete(); } var actual = target.GetEntities( EntityTrackingStates.IsTransient, false ); actual.Contains( person ).Should().Be.True(); }
public void changeTrackingService_using_beginAtomicOperation_getEntities_should_return_all_changed_entities() { var target = new ChangeTrackingService(); var person = new Person( target ); var list = new PersonCollection( target ); using( var op = target.BeginAtomicOperation() ) { person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; op.Complete(); } var actual = target.GetEntities( EntityTrackingStates.HasBackwardChanges, false ); /* * Non funziona perchè non funziona GetEntityState() */ actual.Contains( person ).Should().Be.True(); }
public void changeTrackingService_using_beginAtomicOperation_getEntityState_should_return_valid_entity_state() { var target = new ChangeTrackingService(); var person = new Person( target ); var list = new PersonCollection( target ); using( var op = target.BeginAtomicOperation() ) { person.Name = "Mauro"; list.Add( person ); person.Name = "Mauro Servienti"; op.Complete(); } var actual = target.GetEntityState( person ); actual.Should().Be.EqualTo( EntityTrackingStates.HasBackwardChanges | EntityTrackingStates.IsTransient | EntityTrackingStates.AutoRemove ); }
public async Task<ActionResult> CreateAlert(AlertPresenter alertPresenter, string alertType) { if (alertPresenter != null) { var personData = new PersonCollection(); if (alertType.Equals(SetData, StringComparison.InvariantCultureIgnoreCase)) { var alertData = new Alert { Description = alertPresenter.Description, TypeId = Convert.ToInt32(alertPresenter.SelectedAlertTypes), StartDate = Convert.ToDateTime(alertPresenter.StartDate, CultureInfo.InvariantCulture), ExpiryDate = Convert.ToDateTime(alertPresenter.ExpiryDate, CultureInfo.InvariantCulture), IsOverride = alertPresenter.IsOverrideAllowed, IsSoundEnable = alertPresenter.IsSoundEnable, AlertType = alertPresenter.AlertType, IsTemplate = alertPresenter.IsTemplate, TemplateName = alertPresenter.Description, CrewDepartmentId = alertPresenter.SelectedCrewDepartment }; SessionData.Instance.AssignAlertData(alertData); return this.Json(true); } var alert = new Alert { Description = alertPresenter.Description, TypeId = Convert.ToInt32(alertPresenter.SelectedAlertTypes), Rank = alertPresenter.Rank, StartDate = Convert.ToDateTime(alertPresenter.StartDate, CultureInfo.InvariantCulture), ExpiryDate = Convert.ToDateTime(alertPresenter.ExpiryDate, CultureInfo.InvariantCulture), IsOverride = alertPresenter.IsOverrideAllowed, IsSoundEnable = alertPresenter.IsSoundEnable, AlertType = alertPresenter.AlertType, UserName = !string.IsNullOrWhiteSpace(SessionData.Instance.User.FirstName) ? SessionData.Instance.User.LastName + Comma + SessionData.Instance.User.FirstName : SessionData.Instance.User.LastName, IsTemplate = alertPresenter.IsTemplate, TemplateName = alertPresenter.Description, CrewDepartmentId = alertPresenter.SelectedCrewDepartment }; if (!string.IsNullOrEmpty(SessionData.Instance.ActiveAlertId)) { alert.AlertId = SessionData.Instance.ActiveAlertId; } if (SessionData.Instance.FilterPersonList != null) { foreach (var person in SessionData.Instance.FilterPersonList) { personData.Add(person); } } alert.Persons = personData; var alertDetail = alertType == Update ? await this.alertManager.UpdateAlertAsync(alert, SessionData.Instance.ActiveAlertId) : await this.alertManager.CreateAlertAsync(alert); if (alertDetail != null && SessionData.Instance.FilterPersonList != null) { SessionData.Instance.PassengerSearchItems.Items.Clear(); SessionData.Instance.FilterPersonList.Clear(); SessionData.Instance.ActiveAlertId = string.Empty; SessionData.Instance.GlobalAlertPersonList.Clear(); SessionData.Instance.GlobalMessagePersonList.Clear(); SessionData.Instance.SelectedPersonIds.Clear(); SessionData.Instance.AlertData = null; return this.Json(true); } } return this.Json(false); }