public void SetUp()
        {
            manager = new RsvpManager();

            IMeetupService meetupService = new MeetupService(GetRepository());
            RsvpItems = meetupService.GetRsvpsForEvent(eventId);
        }
        public void Can_get_all_rsvps_for_event()
        {
            IMeetupService meetupService = new MeetupService(GetRepository());
            IList<RsvpItem> rsvps = meetupService.GetRsvpsForEvent(eventId);

            Assert.AreEqual(3, rsvps.Count);
        }
Esempio n. 3
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txbAPIKey.Text) || string.IsNullOrEmpty(txbEventId.Text))
            {
                MessageBox.Show("Please enter all the information on the form.", "Export", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            //load data from meetup should be async
            IMeetupService service = new MeetupService(new MeetupRepository(txbAPIKey.Text));
            IList<RsvpItem> rsvpItems = service.GetRsvpsForEvent(long.Parse(txbEventId.Text));

            //export it
            var saveFileDialog = new SaveFileDialog
                         {
                             InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                             DefaultExt = "csv",
                             AddExtension = true,
                             Filter = @"CSV Files (*.csv)|*.csv"
                         };

            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    File.WriteAllText(saveFileDialog.FileName, new RsvpManager().GetAttendees(rsvpItems).ToCsv(true));
                    MessageBox.Show("Export done.", "Export", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch
                {
                    MessageBox.Show("Export Failed.", "Export", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        public void Name_should_be_populated()
        {
            IMeetupService meetupService = new MeetupService(GetRepository());
            IList<RsvpItem> rsvps = meetupService.GetRsvpsForEvent(eventId);

            var gates = rsvps[0];
            Assert.AreEqual("Bill Gates", gates.Name);
            Assert.AreEqual("Bill Gates", gates.Answers[0]);
            var obama = rsvps[1];
            Assert.AreEqual("Barak Obama", obama.Name);
            Assert.AreEqual("Barak Obama", obama.Answers[0].Split(',')[0].Trim());
            Assert.AreEqual("Mohamed Ahmadinejad", obama.Answers[0].Split(',')[1].Trim());
        }