예제 #1
0
        public void AddPersonShouldAddPersonToPhoneBook()
        {
            bool resultSuccess = phoneBook.AddPerson(new Person("Pesho", "Varna", "087 234 567"));

            Assert.AreEqual(true, resultSuccess);

            bool resultFail = phoneBook.AddPerson(new Person("Pesho", "Varna", "052 23 45 68"));

            Assert.AreEqual(false, resultFail);
        }
예제 #2
0
        public void TestInit()
        {
            _phoneBook = new PhoneBook();

            foreach (var item in GetSampleData())
            {
                _phoneBook.AddPerson(item);
            }
        }
예제 #3
0
        public void addPerson()
        {
            var service = new PhoneBook(_context.Object);
            var person  = new Person("Mickey", "Mouse");

            _context.Setup(mock => mock.SaveChanges()).Returns(1);
            _context.Setup(mock => mock.Persons.Add(person));

            service.AddPerson(person);

            _context.Verify(mock => mock.Persons.Add(person));
            _context.Verify(mock => mock.SaveChanges());
        }
예제 #4
0
        public void addPerson()
        {
            try
            {
                DatabaseUtil.initializeDatabase();

                Person objPerson = new Person()
                {
                    name        = "Test Name",
                    phoneNumber = "(248) 123-4567",
                    address     = "1234 Sand Hill Dr, Royal Oak, MI"
                };
                phonebook.AddPerson(objPerson);
            }
            catch (Exception ex)
            {
                Assert.Fail();
            }
            finally
            {
                DatabaseUtil.CleanUp();
            }
        }
예제 #5
0
        public void addPerson()
        {
            Person testEntity = new Person()
            {
                name        = "John Smith",
                address     = "1234 Sand Hill Dr, Royaml Oak, MI",
                phoneNumber = "(248) 123-4567"
            };

            //  Check thats the database exists
            Assert.IsTrue(DatabaseUtil.checkDatabaseExists("MyDatabase.sqlite", "MyDatabase"));

            //Add person to database
            phonebook.AddPerson(testEntity);

            //  return the person and check
            Person returnedEntity = phonebook.FindPerson("John", "smith");

            Assert.IsNotNull(returnedEntity);
            Assert.AreSame("John Smith", returnedEntity.name);
            Assert.AreSame("1234 Sand Hill Dr, Royaml Oak, MI", returnedEntity.address);
            Assert.AreSame("(248) 123-4567", returnedEntity.phoneNumber);
        }
예제 #6
0
        public void Should_AddPersonToDatabase()
        {
            //arrange
            ApplicationDbContext context   = new ApplicationDbContext();
            IPhoneBook           phoneBook = new PhoneBook(context);

            //act
            phoneBook.AddPerson(new Person
            {
                Address     = "1234 Sand Hill Dr, Royal Oak, MI",
                Name        = "John Smith",
                PhoneNumber = "(248) 123-4567"
            });

            //assert
            Assert.AreEqual("John Smith", context.PhoneBook.OrderByDescending(x => x.Id).FirstOrDefault()?.Name);
        }
예제 #7
0
        public void ShouldAddNewPerson()
        {
            // Arrange
            var person = new Person
            {
                Name    = "E",
                Surname = "E",
                Phone   = "5"
            };

            // Act
            var result = _phoneBook.AddPerson(person);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(5, _phoneBook.GetBook().Count);
        }
예제 #8
0
        public void AddPerson_Fail()
        {
            //arrange
            Person person = new Person
            {
                Name        = "New Smith",
                PhoneNumber = "(248) 555-1234",
                Address     = "1234 Test Dr, Royal Oak, MI"
            };

            _phoneBookDataProvider.Setup(m => m.AddPerson(person)).Returns(false);
            var phoneBook = new PhoneBook(_phoneBookDataProvider.Object);

            //act
            var result = phoneBook.AddPerson(person);

            //assert
            Assert.IsTrue(!result);
        }
예제 #9
0
 public ArrangementBuilder WithPersonAdded()
 {
     this.person = new Person("first last", "phoneNumber", "address");
     phoneBook.AddPerson(person);
     return(this);
 }
예제 #10
0
        private static PhoneBook LoadPhoneBook()
        {
            var phoneBook = new PhoneBook();

            phoneBook.AddPerson(new Person
            {
                FirstName = "John",
                LastName  = "Smith",
                Age       = 44,
                Address   = new Address
                {
                    Country       = "US",
                    City          = "New York",
                    State         = "New York",
                    StreetAddress = "241812 fictive lane",
                    ZipCode       = 12358
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Tom",
                LastName  = "Jacobson",
                Age       = 60,
                Address   = new Address
                {
                    Country       = "UK",
                    City          = "London",
                    StreetAddress = "21 Baker St.",
                    ZipCode       = 43245
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Sandra",
                LastName  = "Jones",
                Age       = 25,
                Address   = new Address
                {
                    Country       = "US",
                    City          = "Paris",
                    State         = "Texas",
                    StreetAddress = "1234 made up lane",
                    ZipCode       = 11111
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Vanessa",
                LastName  = "Biju",
                Age       = 72,
                Address   = new Address
                {
                    Country       = "DE",
                    City          = "Hamburg",
                    StreetAddress = "12244-24432423-432234",
                }
            });

            return(phoneBook);
        }
예제 #11
0
        private static PhoneBook LoadPhoneBook()
        {
            var phoneBook = new PhoneBook();
            phoneBook.AddPerson(new Person
            {
                FirstName = "John",
                LastName = "Smith",
                Age = 44,
                Address = new Address
                {
                    Country = "US",
                    City = "New York",
                    State = "New York",
                    StreetAddress = "241812 fictive lane",
                    ZipCode = 12358
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Tom",
                LastName = "Jacobson",
                Age = 60,
                Address = new Address
                {
                    Country = "UK",
                    City = "London",
                    StreetAddress = "21 Baker St.",
                    ZipCode = 43245
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Sandra",
                LastName = "Jones",
                Age = 25,
                Address = new Address
                {
                    Country = "US",
                    City = "Paris",
                    State = "Texas",
                    StreetAddress = "1234 made up lane",
                    ZipCode = 11111
                }
            });

            phoneBook.AddPerson(new Person
            {
                FirstName = "Vanessa",
                LastName = "Biju",
                Age = 72,
                Address = new Address
                {
                    Country = "DE",
                    City = "Hamburg",
                    StreetAddress = "12244-24432423-432234",
                }
            });

            return phoneBook;
        }