コード例 #1
0
        public void Test_Delete_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            ContactInfo firstContactInfo = new ContactInfo("123 First st. Portland, OR", 1234567890, 2);

            firstContactInfo.Save();

            ContactInfo secondContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 2);

            secondContactInfo.Save();

            ContactInfo thirdContactInfo = new ContactInfo("316 10th st. Brooklyn, NY", 2024567890, 2);

            thirdContactInfo.Save();

            List <ContactInfo> expectedList = new List <ContactInfo> {
                firstContactInfo, secondContactInfo
            };

            //Act
            thirdContactInfo.Delete();
            List <ContactInfo> contactList = ContactInfo.GetAll();

            //Assert
            Assert.Equal(contactList, expectedList);
        }
コード例 #2
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1);

            //Act
            testContactInfo.Save();
            ContactInfo savedContactInfo = ContactInfo.GetAll()[0];
            int         result           = savedContactInfo.GetId();
            int         testId           = testContactInfo.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
コード例 #3
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1);

            //Act
            testContactInfo.Save();
            List <ContactInfo> result   = ContactInfo.GetAll();
            List <ContactInfo> testList = new List <ContactInfo> {
                testContactInfo
            };

            //Assert
            Assert.Equal(testList, result);
        }
コード例 #4
0
        public void Test_DatabaseEmptyAtFirst()
        {
            int result = ContactInfo.GetAll().Count;

            Assert.Equal(0, result);
        }