コード例 #1
0
        public void CanGetCreatedEvent()
        {
            var eventRepository = MockRepository.GenerateStub<IEventRepository>();
            var expectedEventDto = new EventDto
            {
                EventId = 1
            };
            eventRepository
                .Expect(et => et.GetItem(1))
                .Return(expectedEventDto);

            var permissionRepository = new PermissionRepository();
            var personRepository = new PersonRepository(permissionRepository, new ChurchRepository());
            var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository);
            var groupRepository = new GroupRepository();
            var messageRepository = new MessageRepository();
            var messageRecepientRepository = new MessageRecepientRepository();
            var messageAttachmentRepository = new MessageAttachmentRepository();
            var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository);
            var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository();
            var emailContentRepository = new EmailContentRepository();
            var emailContentService = new EmailContentService(emailContentRepository);
            var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository);

            IEventService eventService = new EventService(eventRepository, emailService, new BirthdayAndAniversaryRepository());
            var eventDto = eventService.GetEvent(1);
            Assert.That(eventDto, Is.EqualTo(expectedEventDto));
        }
コード例 #2
0
        public void CanCreateANewEvent()
        {
            var eventTypeRepository = MockRepository.GenerateStub<IEventRepository>();

            var permissionRepository = new PermissionRepository();
            var personRepository = new PersonRepository(permissionRepository, new ChurchRepository());
            var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository);
            var groupRepository = new GroupRepository();
            var messageRepository = new MessageRepository();
            var messageRecepientRepository = new MessageRecepientRepository();
            var messageAttachmentRepository = new MessageAttachmentRepository();
            var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository);
            var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository();
            var emailContentRepository = new EmailContentRepository();
            var emailContentService = new EmailContentService(emailContentRepository);
            var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository);
            IEventService eventTypeService = new EventService(eventTypeRepository, emailService, new BirthdayAndAniversaryRepository());
            var newEvent = new EventDto();
            eventTypeRepository
                .Expect(e => e.SaveItem(newEvent))
                .Return(1);
            var result = eventTypeService.CreateEvent(newEvent);

            Assert.That(result, Is.EqualTo(1));
        }
コード例 #3
0
ファイル: EventRepository.cs プロジェクト: rodown/funwithoiky
        int IEventRepository.SaveItem(EventDto eventDto)
        {
            var existingEvent = _context.Events.FirstOrDefault(e => e.ChurchId == eventDto.ChurchId && e.Name == eventDto.Name);
            if (existingEvent != null)
                return existingEvent.EventId;

            var newEvent = new Event();
            Mapper.Map(eventDto, newEvent);
            _context.AddToEvents(newEvent);
            _context.SaveChanges();
            return newEvent.EventId;
        }
コード例 #4
0
ファイル: EventTests.cs プロジェクト: rodown/funwithoiky
        public void CanCreateANewEvent()
        {
            var eventTypeRepository = MockRepository.GenerateStub<IEventRepository>();

            IEventService eventTypeService = new EventService(eventTypeRepository);
            var newEvent = new EventDto();
            eventTypeRepository
                .Expect(e => e.SaveItem(newEvent))
                .Return(1);
            var result = eventTypeService.CreateEvent(newEvent);

            Assert.That(result, Is.EqualTo(1));
        }
コード例 #5
0
ファイル: EventTests.cs プロジェクト: rodown/funwithoiky
        public void CanGetCreatedEvent()
        {
            var eventRepository = MockRepository.GenerateStub<IEventRepository>();
            var expectedEventDto = new EventDto
            {
                EventId = 1
            };
            eventRepository
                .Expect(et => et.GetItem(1))
                .Return(expectedEventDto);

            IEventService eventService = new EventService(eventRepository);
            var eventDto = eventService.GetEvent(1);
            Assert.That(eventDto, Is.EqualTo(expectedEventDto));
        }
コード例 #6
0
ファイル: EventTests.cs プロジェクト: rodown/funwithoiky
        public void CanGetCreatedItem()
        {
            IEventRepository eventRepository = new EventRepository(Context);
            const string testName            = "Test Event";

            var newEventDto = new EventDto
                                      {
                                          ChurchId = 1,
                                          Name = testName
                                      };

            var eventId     = eventRepository.SaveItem(newEventDto);
            var eventItem   = eventRepository.GetItem(eventId);

            Assert.That(eventItem.Name, Is.EqualTo(testName));

            eventRepository.DeleteItem(eventId);
        }
コード例 #7
0
ファイル: EventService.cs プロジェクト: rodown/funwithoiky
 public void UpdateEvent(EventDto eventDto)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
ファイル: EventService.cs プロジェクト: rodown/funwithoiky
 public int CreateEvent(EventDto eventDto)
 {
     throw new NotImplementedException();
 }