Exemplo n.º 1
0
        public async Task SeedDatabase()
        {
            var eventLogger     = Mock.Of <ILogger <EventService> >();
            var eventItemLogger = Mock.Of <ILogger <ItemService> >();
            var contactLogger   = Mock.Of <ILogger <ContactService> >();
            var contactService  = new ContactService(ContactRepository, Mapper, contactLogger);

            var fakeContacts = FakeData.FakeContacts();

            foreach (var fakeContact in fakeContacts)
            {
                await contactService.CreateAsync(fakeContact);
            }

            var contacts = await contactService.SearchAsync(new ContactSearchRequest());

            var creatorId        = contacts.First().Id;
            var data             = FakeData.FakeEvents(creatorId);
            var eventService     = new EventService(EventRepository, Mapper, eventLogger);
            var eventItemService = new ItemService(EventItemRepository, Mapper, eventItemLogger);

            foreach (var model in data)
            {
                var saved = await eventService.CreateAsync(model);

                var items = FakeData.FakeEventItems(creatorId, saved.Id, 12);
                foreach (var item in items)
                {
                    await eventItemService.CreateAsync(item);
                }
            }
        }