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); }
public void TestInit() { _phoneBook = new PhoneBook(); foreach (var item in GetSampleData()) { _phoneBook.AddPerson(item); } }
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()); }
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(); } }
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); }
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); }
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); }
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); }
public ArrangementBuilder WithPersonAdded() { this.person = new Person("first last", "phoneNumber", "address"); phoneBook.AddPerson(person); return(this); }
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); }
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; }