Exemplo 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]);
        }
Exemplo n.º 2
0
        // GET: Contacts
        public ActionResult Index(string searchKey, int Index = 1, int pageSize = 6)
        {
            //当前分页数据集合
            var model    = new ContactsApp().GetCustorms(searchKey, Index, pageSize);
            var newmodel = model.Skip((Index - 1) * pageSize).Take(pageSize);
            //当前ViewModel传递试图
            BasePageModel page = new BasePageModel()
            {
                SearchKeyWord = searchKey
                ,
                CurrentIndex = Int32.Parse(Index.ToString()), TotalCount = model.Count()
            };

            ViewData["pagemodel"] = page;
            return(View(new ContactsViewModel {
                SearchKey = searchKey,
                Posts = newmodel,
                PageModel = page,
                PagingInfo = new Models.PagingInfo {
                    TotalItems = model.Count(),
                    PageIndex = Index,
                    PageSize = pageSize
                }
            }));
        }
Exemplo 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);
            });
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
            });
        }