Exemple #1
0
        public async void ListSessionsBySpeaker_ValidSpeakerId_ReturnsSessionsForSpeaker()
        {
            int speakerId      = 1;
            var correctSession = new Session {
                Id = 2, SpeakerId = speakerId
            };
            var wrongSession = new Session {
                Id = 3, SpeakerId = speakerId + 1
            };
            var campData = new CampData
            {
                Sessions = new List <Session> {
                    correctSession, wrongSession
                },
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = speakerId
                    }
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);

            var sessions = await service.ListSessionsBySpeaker(speakerId);

            Assert.AreEqual(1, sessions.Count);
            Assert.AreEqual(correctSession, sessions.First());
        }
Exemple #2
0
        public async void GetData_FirstCall_FetchesData()
        {
            var campData = new CampData
            {
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = 1
                    }
                },
                Sessions = new List <Session> {
                    new Session {
                        Title = "Best Session Ever", Id = 42, SpeakerId = 1
                    }
                }
            };
            bool clientCalled = false;

            _mockDataClient.GetDataBody = () =>
            {
                clientCalled = true;
                return(Task.FromResult(campData));
            };

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);

            var data = await service.GetData();

            Assert.True(clientCalled);
            Assert.AreEqual(campData, data);
        }
Exemple #3
0
        public async void GetSession_ValidSessionId_ReturnsSession()
        {
            var awesomeSession = new Session {
                Title = "Best Session Ever", Id = 42, SpeakerId = 1
            };
            var campData = new CampData
            {
                Sessions = new List <Session> {
                    awesomeSession
                },
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = 1
                    }
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);

            var session = await service.GetSession(awesomeSession.Id);

            Assert.AreEqual(awesomeSession, session);
        }
Exemple #4
0
        // TODO Support multiple environments
        // TODO HTTP logger option
        private static void SetupCodeCampService()
        {
            try
            {
                var baseUrl = Urls.CodeCampUrl;

                CodeCampService = new CodeCampService(baseUrl);
            }
            catch (Exception exception)
            {
                SendErrorMessage(exception);
            }
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCampTest"/> class.
        /// </summary>
        public CodeCampTest()
        {
            var mockRepo = new Mock <ICodeCampRepository>();

            IList <CodeCamp> codeCamps = new List <CodeCamp>()
            {
                new CodeCamp
                {
                    Moniker   = "99xCodeCamp",
                    Id        = 1,
                    Sessions  = null,
                    Name      = "99x Code Camp",
                    EventDate = DateTime.Today.AddDays(1),
                    Length    = 4,
                    Location  = null
                },
                new CodeCamp
                {
                    Moniker   = "99xCodeCamp2",
                    Id        = 1,
                    Sessions  = null,
                    Name      = "99x Code Camp Two",
                    EventDate = DateTime.Today.AddDays(1),
                    Length    = 4,
                    Location  = null
                }
            };

            mockRepo.Setup(mr => mr.GetCampByMonikerAsync(
                               It.IsAny <string>(), false)).ReturnsAsync((string s, bool b) => codeCamps.SingleOrDefault(x => x.Moniker == s));

            mockRepo.Setup(repo => repo.GetAllAsync(false))
            .ReturnsAsync(codeCamps);

            mockRepo.Setup(mr => mr.Insert(It.IsAny <CodeCamp>()))
            .Callback((CodeCamp codeCamp) =>
            {
                codeCamp.Id = codeCamps.Count() + 1;
                codeCamps.Add(codeCamp);
            }).Verifiable();

            mockRepo.SetupAllProperties();
            _mapper          = MapperConfig.GetMapper();
            _codeCampService = new CodeCampService(mockRepo.Object, _mapper);
        }
Exemple #6
0
        public async void ListSpeakers_FetchesDataAndReturnsSpeakers()
        {
            var campData = new CampData
            {
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = 42
                    }
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service  = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);
            var speakers = await service.ListSpeakers();

            Assert.AreEqual(campData.Speakers, speakers);
        }
Exemple #7
0
        public async void GetSponsor_ValidSponsorId_ReturnsSponsor()
        {
            var awesomeSponsor = new Sponsor {
                Id = 42
            };
            var campData = new CampData
            {
                Sponsors = new List <Sponsor> {
                    awesomeSponsor
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);

            var sponsor = await service.GetSponsor(awesomeSponsor.Id);

            Assert.AreEqual(awesomeSponsor, sponsor);
        }
Exemple #8
0
        public async void ListSponsors_FetchesDataAndReturnsSponsors()
        {
            var sponsor = new Sponsor {
                Id = 42, Tier = "Gold"
            };
            var campData = new CampData
            {
                Sponsors = new List <Sponsor> {
                    sponsor
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);
            var tiers   = await service.ListSponsors();

            Assert.AreEqual(1, tiers.Count);
            Assert.AreEqual(1, tiers.First().Sponsors.Count);
            Assert.AreEqual(sponsor, tiers.First().Sponsors.First());
        }
Exemple #9
0
		public override bool FinishedLaunching(UIApplication app, NSDictionary options)
		{
			_waitingView = new WaitingView();
			
			subscribeToMessages();
			
			CodeCampService = new CodeCampService("http://codecamps.gregshackles.com/v1", "nyccodecamp6");
			
			_tabController = new TabController();
			_tabController.View.BackgroundColor = UIColor.Clear;
			
			var backgroundImage = new UIImageView(UIImage.FromFile("Content/Images/background.png"));
			backgroundImage.UserInteractionEnabled = true;
			backgroundImage.Frame = new System.Drawing.RectangleF(0, 0, window.Frame.Width, window.Frame.Height);
			backgroundImage.AddSubview(_tabController.View);
			
			window.AddSubview(backgroundImage);
			
			window.MakeKeyAndVisible ();
	
			return true;
		}
Exemple #10
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            int id;
            var service = new CodeCampService();

            var defaultEvent = service.GetDefaultEvent();

            id = defaultEvent.ID;

            routes.MapRoute(
                "Default",                    // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { eventid = id, controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );

            routes.MapRoute(
                "Archive",                                 // Route name
                "Archive/{eventid}/{controller}/{action}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );
        }
Exemple #11
0
        public async void ListSessions_FetchesDataAndReturnsSessions()
        {
            var session = new Session
            {
                Title     = "Best Session Ever",
                Id        = 42,
                StartTime = DateTime.UtcNow,
                EndTime   = DateTime.UtcNow,
                SpeakerId = 1
            };
            var campData = new CampData
            {
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = session.SpeakerId.Value
                    }
                },
                Sessions = new List <Session> {
                    session
                }
            };

            _mockDataClient.GetDataBody = () => Task.FromResult(campData);

            var service = new CodeCampService(_fileManager, _jsonConverter, _mockDataClient);

            var timeSlots = await service.ListSessions();

            Assert.AreEqual(1, timeSlots.Count);

            var slot = timeSlots.First();

            Assert.AreEqual(session.StartTime, slot.StartTime);
            Assert.AreEqual(session.EndTime, slot.EndTime);
            Assert.AreEqual(1, slot.Sessions.Count);
            Assert.AreEqual(session, slot.Sessions.First());
        }
Exemple #12
0
        private void SetFormsAuth(CodeCampService.Person authenticatedPerson, bool rememberMe)
        {
            this.CurrentUser = authenticatedPerson.Map();

            HttpContext.Session.Add("auth", true);
            HttpContext.User = CurrentUser;

            SetPersonRoles(this.CurrentUser);

            CreateAuthTicket(rememberMe);

            // FormsAuthentication.SetAuthCookie(CurrentUser.Email, false);
            // ???
        }