Ejemplo n.º 1
0
        public void PutSession_NotFail_Test()
        {
            bool called = false;
            var expectedSession = new Session() { SessionId = 1 };
            var eventDefinition = new EventDefinition() { OrganizerId = 1 };

            IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository()
            {
                GetByIdInt32 = (id) =>
                {
                    Assert.AreEqual(expectedSession.EventDefinitionId, id);
                    return eventDefinition;
                }
            };
            ISessionRepository sessionRepository = new StubISessionRepository()
            {
                UpdateSession = session =>
                {
                    Assert.AreEqual(expectedSession.SessionId, session.SessionId);
                    called = true;
                }
            };

            using (ShimsContext.Create())
            {
                MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken();
                myeventToken.RegisteredUserIdGet = () => { return eventDefinition.OrganizerId; };
                ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; };

                var target = new SessionsController(sessionRepository, eventRepository);

                target.Put(expectedSession);

                Assert.IsTrue(called);
            }
        }
Ejemplo n.º 2
0
        public void PutSession_UnauthorizedException_Test()
        {
            var expectedSession = new Session() { SessionId = 1 };
            var eventDefinition = new EventDefinition() { OrganizerId = 1 };

            IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository()
            {
                GetByIdInt32 = (id) =>
                {
                    Assert.AreEqual(expectedSession.EventDefinitionId, id);
                    return eventDefinition;
                }
            };
            ISessionRepository sessionRepository = new StubISessionRepository();
            using (ShimsContext.Create())
            {
                MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken();
                myeventToken.RegisteredUserIdGet = () => { return 1000; };
                ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; };

                var target = new SessionsController(sessionRepository, eventRepository);

                target.Put(expectedSession);
            }
        }
Ejemplo n.º 3
0
        public void PutSession_ArgumentNullException_Test()
        {
            ISessionRepository sessionRepository = new StubISessionRepository();
            IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository();

            var target = new SessionsController(sessionRepository, eventRepository);

            target.Put(null);
        }