private PhonebookEntry CreateEntry(Domain.Entities.Phonebook phonebook, string name, string number)
        {
            var entry = PhonebookEntryFactory.Create(phonebook);

            entry.Name        = name;
            entry.PhoneNumber = number;
            return(entry);
        }
        public void Setup()
        {
            options = new DbContextOptionsBuilder <AbsaPhonebookContext>().UseInMemoryDatabase(databaseName: "AbsaPhonebook").Options;
            var context = new AbsaPhonebookContext(options);

            context.RemoveRange(context.Phonebook);
            context.RemoveRange(context.PhonebookEntry);
            context.SaveChanges();

            phonebook      = PhonebookFactory.Create();
            phonebook.Name = "Stellenbosch Directory";

            phonebook.PhonebookEntries.Add(CreateEntry(phonebook, "Dave Worthington", "021979452"));
            phonebookEntry = CreateEntry(phonebook, "Bill Lumsden", "0215554334");
            phonebook.PhonebookEntries.Add(phonebookEntry);
            repository      = new PhonebookRepository(context);
            entryRepository = new PhonebookEntryRepository(context);

            repository.Add(phonebook);
            repository.Commit();

            controller = new PhonebookController(repository, entryRepository);
        }
Exemple #3
0
 public PhonebookEntry(Phonebook phonebook)
 {
     PhonebookId = phonebook.Id;
 }