Ejemplo n.º 1
0
        public void GivenNewTechSupportAndSourcePhoneWithAContactAndTargetPhoneWithNoContact_WhenCopyingContacts_ThenContactInTargetShouldNotBeSameReference()
        {
            //GivenNewTechSupport
            TechSupport techSupport = new TechSupport();

            //AndSourcePhoneWithAContact
            Contact s1 = new Contact()
            {
                Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
            };

            Phone source = new Phone()
            {
                Brand = "Source", Model = "Phone"
            };
            ContactsApp sourceContacts = new ContactsApp();

            sourceContacts.Contacts.Add(s1);
            source.AppDrawer.Install(sourceContacts);

            //AndTargetPhoneWithNoContact
            Phone target = new Phone()
            {
                Brand = "Target", Model = "Phone"
            };
            ContactsApp targetContacts = new ContactsApp();

            target.AppDrawer.Install(targetContacts);

            //WhenCopyingContacts
            techSupport.CopyContacts(source, target);

            //ThenContactInTargetShouldNotBeSameReference
            Assert.NotSame(s1, targetContacts.Contacts[0]);
        }
Ejemplo n.º 2
0
        public void CopyShouldCopyTheContactsFromSourceToTargetPhone()
        {
            //arrange

            //create a contact
            Contact superMario = new Contact();

            //fill a contact with info
            superMario.Name        = "SuperMario";
            superMario.PhoneNumber = "06123456789";

            //create a source phone
            Phone sourcePhone = new Phone();

            //fill the source phone with the contact
            //sourcePhone.Contacts[0] = superMario;
            sourcePhone.AddContact(superMario);

            //create a target phone
            Phone targetPhone = new Phone();

            //create a techsupport guy
            TechSupport theGuy = new TechSupport();

            //act
            theGuy.CopyContacts(sourcePhone, targetPhone);
            //ask the techtsupport guy to copy the contacts from the source to the target phone


            //assert

            //source and target contacts are the same collection
        }
Ejemplo n.º 3
0
        public void GivenNewTechSupportAndSourcePhoneWithAContactAndTargetPhoneWithAContactWithSameNameAndPhoneNumber_WhenCopyingContacts_ThenTargetPhoneShouldHaveTargetPlusSourceContacts()
        {
            //GivenNewTechSupport
            TechSupport techSupport = new TechSupport();

            //AndSourcePhoneWithAContacts
            Contact s1 = new Contact()
            {
                Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
            };

            Phone source = new Phone()
            {
                Brand = "Source", Model = "Phone"
            };
            ContactsApp sourceContacts = new ContactsApp();

            sourceContacts.Contacts.Add(s1);
            source.AppDrawer.Install(sourceContacts);

            //AndTargetPhoneWith2Contacts
            Phone target = new Phone()
            {
                Brand = "Target", Model = "Phone"
            };

            Contact t1 = new Contact()
            {
                Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
            };
            ContactsApp targetContacts = new ContactsApp();

            targetContacts.Contacts.Add(t1);
            target.AppDrawer.Install(targetContacts);

            //WhenCopyingContacts
            techSupport.CopyContacts(source, target);

            //ThenTargetPhoneShouldHaveTargetPlusSourceContacts
            Assert.Collection(targetContacts.Contacts,
                              item => {
                Assert.Equal(t1.Name, item.Name);
                Assert.Equal(t1.Surname, item.Surname);
                Assert.Equal(t1.PhoneNumber, item.PhoneNumber);
            },
                              item => {
                Assert.Equal(s1.Name, item.Name);
                Assert.Equal(s1.Surname, item.Surname);
                Assert.Equal(s1.PhoneNumber, item.PhoneNumber);
            });
        }
Ejemplo n.º 4
0
        private void techDocListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                string userName = Properties.Settings.Default.UserName;
                string password =
                    String.IsNullOrEmpty(Properties.Settings.Default.Password) ?
                    String.Empty :
                    Utility.UnprotectData(Properties.Settings.Default.Password);

                if (String.IsNullOrEmpty(userName))
                {
                    SimpleInputBox sib = new SimpleInputBox();
                    sib.Title     = "Username";
                    sib.MaskInput = false;
                    if (sib.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    userName = sib.TextValue;
                }

                if (String.IsNullOrEmpty(password))
                {
                    SimpleInputBox sib = new SimpleInputBox();
                    sib.Title     = "Password";
                    sib.MaskInput = true;
                    if (sib.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    password = sib.TextValue;
                }

                MessageBox.Show("Starting");

                TechSupport.ExportDocList(fbd.SelectedPath, userName, password);

                MessageBox.Show("Done");
            }
        }
Ejemplo n.º 5
0
        public void GivenNewTechSupportAndPhoneWith3ContactsAndPhoneWithNoContacts_WhenCopyingContacts_ThenTargetPhoneShouldHave3Contacts()
        {
            //GivenNewTechSupport
            TechSupport techSupport = new TechSupport();
            //AndPhoneWith3Contacts
            Phone source = new Phone()
            {
                Brand = "Source", Model = "Phone"
            };
            ContactsApp sourceContacts = new ContactsApp();

            sourceContacts.Contacts.AddRange(new[] {
                new Contact()
                {
                    Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
                },
                new Contact()
                {
                    Name = "Luigi", Surname = "Super", PhoneNumber = "06123124"
                },
                new Contact()
                {
                    Name = "Princess", Surname = "Peach", PhoneNumber = "06765765"
                }
            });
            source.AppDrawer.Install(sourceContacts);

            //AndPhoneWithNoContacts
            Phone target = new Phone()
            {
                Brand = "Target", Model = "Phone"
            };
            ContactsApp targetContacts = new ContactsApp();

            target.AppDrawer.Install(targetContacts);

            //WhenCopyingContacts
            techSupport.CopyContacts(source, target);

            //ThenTargetPhoneShouldHave3Contacts
            Assert.True(targetContacts.Contacts.Count == 3);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Phone oldPhone = new Phone()
            {
                Brand = "Samsung", Model = "S5"
            };

            oldPhone.Contacts.AddRange(new[] {
                new Contact()
                {
                    Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
                },
                new Contact()
                {
                    Name = "Luigi", Surname = "Super", PhoneNumber = "06123124"
                },
                new Contact()
                {
                    Name = "Princess", Surname = "Peach", PhoneNumber = "06765765"
                }
            });

            Phone newPhoneWhoDis = new Phone()
            {
                Brand = "WhoDis", Model = "NewPhone"
            };
            TechSupport yeOldeTechSupport = new TechSupport();

            yeOldeTechSupport.CopyContacts(oldPhone, newPhoneWhoDis);

            foreach (Contact item in newPhoneWhoDis.Contacts)
            {
                Console.WriteLine($"{item.Name} {item.Surname} {item.PhoneNumber}");
            }

            Console.ReadLine();
        }
Ejemplo n.º 7
0
        public void GivenAPhoneWith5ContactsAndAPhoneWithNoContactsAndATechSupport_WhenCopyinTheContactsFromPhone1ToPhone2_ThenTheContactsInPhone2ShouldBeTheSameOfPhone1()
        {
            //GivenAPhone
            Phone sourcePhone = new Phone();
            //With5Contacts
            Contact c1 = new Contact();

            c1.Name        = "C1";
            c1.PhoneNumber = "PN1";

            Contact c2 = new Contact()
            {
                Name = "C2", PhoneNumber = "PN2"
            };

            sourcePhone.AddContact(c1.Name, c1.PhoneNumber);
            sourcePhone.AddContact(c2.Name, c2.PhoneNumber);
            sourcePhone.AddContact("C3", "PN3");
            sourcePhone.AddContact("C4", "PN4");
            sourcePhone.AddContact("C5", "PN5");

            //AndAPhone
            Phone targetPhone = new Phone();
            //WithNoContacts
            //AndATechSupport
            TechSupport techSupport = new TechSupport();

            //WhenCopyingTheContactsFromPhone1ToPhone2
            techSupport.CopyContacts(sourcePhone, targetPhone);

            //ThenTheContactsInPhone2ShouldBeTheSameOfPhone1
            for (int i = 0; i < sourcePhone.ContactsCount; i++)
            {
                Assert.AreEqual(sourcePhone.GetContactAt(i).Name, targetPhone.GetContactAt(i).Name);
                Assert.AreEqual(sourcePhone.GetContactAt(i).PhoneNumber, targetPhone.GetContactAt(i).PhoneNumber);
            }
        }
Ejemplo n.º 8
0
        public void GivenNewTechSupportAndSourcePhoneWith3ContactsAndTargetPhoneWith2Contacts_WhenCopyingContacts_ThenTargetPhoneShouldHaveTargetPlusSourceContacts()
        {
            //GivenNewTechSupport
            TechSupport techSupport = new TechSupport();

            //AndSourcePhoneWith3Contacts
            Contact s1 = new Contact()
            {
                Name = "Mario", Surname = "Super", PhoneNumber = "06123123"
            };
            Contact s2 = new Contact()
            {
                Name = "Luigi", Surname = "Super", PhoneNumber = "06123124"
            };
            Contact s3 = new Contact()
            {
                Name = "Princess", Surname = "Peach", PhoneNumber = "06765765"
            };

            Phone source = new Phone()
            {
                Brand = "Source", Model = "Phone"
            };
            ContactsApp sourceContacts = new ContactsApp();

            sourceContacts.Contacts.AddRange(new[] { s1, s2, s3 });
            source.AppDrawer.Install(sourceContacts);

            //AndTargetPhoneWith2Contacts
            Phone target = new Phone()
            {
                Brand = "Target", Model = "Phone"
            };

            Contact t1 = new Contact()
            {
                Name = "Spider", Surname = "Man", PhoneNumber = "06555123"
            };
            Contact t2 = new Contact()
            {
                Name = "Bat", Surname = "Man", PhoneNumber = "06999876"
            };
            ContactsApp targetContacts = new ContactsApp();

            targetContacts.Contacts.AddRange(new[] { t1, t2 });
            target.AppDrawer.Install(targetContacts);

            //WhenCopyingContacts
            techSupport.CopyContacts(source, target);

            //ThenTargetPhoneShouldHaveTargetPlusSourceContacts
            Assert.Collection(targetContacts.Contacts,
                              item => {
                Assert.Equal(t1.Name, item.Name);
                Assert.Equal(t1.Surname, item.Surname);
                Assert.Equal(t1.PhoneNumber, item.PhoneNumber);
            },
                              item => {
                Assert.Equal(t2.Name, item.Name);
                Assert.Equal(t2.Surname, item.Surname);
                Assert.Equal(t2.PhoneNumber, item.PhoneNumber);
            },
                              item => {
                Assert.Equal(s1.Name, item.Name);
                Assert.Equal(s1.Surname, item.Surname);
                Assert.Equal(s1.PhoneNumber, item.PhoneNumber);
            },
                              item => {
                Assert.Equal(s2.Name, item.Name);
                Assert.Equal(s2.Surname, item.Surname);
                Assert.Equal(s2.PhoneNumber, item.PhoneNumber);
            },
                              item => {
                Assert.Equal(s3.Name, item.Name);
                Assert.Equal(s3.Surname, item.Surname);
                Assert.Equal(s3.PhoneNumber, item.PhoneNumber);
            });
        }