コード例 #1
0
        public void DeleteRoomPoints_Unauthorized_Test()
        {
            int expectedEventDefinitionId = 1;
            int expectedRoomNumber = 20;

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                GetByIdInt32 = (id) =>
                {
                    Assert.IsTrue(id == expectedEventDefinitionId);
                    return new EventDefinition() { OrganizerId = 1 };
                }
            };

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

                var target = new RoomPointsController(eventDefinitionService);

                target.DeleteRoomPoints(expectedEventDefinitionId, expectedRoomNumber);
            }
        }
コード例 #2
0
        public void DeleteRoomPoints_NotFail_Test()
        {
            bool called = false;
            int expectedEventDefinitionId = 1;
            int expectedRoomNumber = 20;

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                DeleteRoomPointsInt32Int32 = (eventDefinitionId, roomNumber) =>
                {
                    Assert.AreEqual(expectedEventDefinitionId, eventDefinitionId);
                    Assert.AreEqual(expectedRoomNumber, roomNumber);
                    called = true;
                },
                GetByIdInt32 = (id) =>
                {
                    Assert.IsTrue(id == expectedEventDefinitionId);
                    return new EventDefinition() { OrganizerId = 1 };
                }
            };

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

                var target = new RoomPointsController(eventDefinitionService);

                target.DeleteRoomPoints(expectedEventDefinitionId, expectedRoomNumber);

                Assert.IsTrue(called);
            }
        }
コード例 #3
0
        public void GetAllRoomPoints_NotFail_Test()
        {
            bool called = false;
            var expected = new List<RoomPoint>() { new RoomPoint(), new RoomPoint(), new RoomPoint() };
            var expectedEventId = 1;

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                GetAllRoomPointsInt32 = (eventId) =>
                {
                    Assert.AreEqual(expectedEventId, eventId);
                    called = true;
                    return expected;
                }
            };

            var target = new RoomPointsController(eventDefinitionService);

            var result = target.GetAllRoomPoints(expectedEventId);

            Assert.IsTrue(called);
            Assert.IsNotNull(result);
        }
コード例 #4
0
 public void RoomPointsController_Contructor_NotFail_Test()
 {
     IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository();
     var target = new RoomPointsController(eventDefinitionService);
 }
コード例 #5
0
 public void RoomPointsController_ContructorWithNullDependency_Fail_Test()
 {
     var target = new RoomPointsController(null);
 }
コード例 #6
0
        public void PutRoomImage_UnauthorizedException_Test()
        {
            var expected = new List<RoomPoint>()
            { new RoomPoint() { EventDefinitionId = 10 }
                , new RoomPoint() { EventDefinitionId = 10 }
                , new RoomPoint() { EventDefinitionId = 10 }};
            EventDefinition expectedEvent = new EventDefinition() { EventDefinitionId = 10, OrganizerId = 10 };

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                GetByIdInt32 = (id) =>
                {
                    Assert.IsTrue(id == expectedEvent.EventDefinitionId);
                    return expectedEvent;
                }
            };

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

                var target = new RoomPointsController(eventDefinitionService);

                target.PutRoomImage(expectedEvent);
            }
        }
コード例 #7
0
        public void PutRoomImage_NotFail_Test()
        {
            bool called = false;
            var expected = new List<RoomPoint>()
            { new RoomPoint() { EventDefinitionId = 10 }
                , new RoomPoint() { EventDefinitionId = 10 }
                , new RoomPoint() { EventDefinitionId = 10 }};
            EventDefinition expectedEvent = new EventDefinition() { EventDefinitionId = 10 , OrganizerId = 10};

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                UpdateRoomImageEventDefinition = (eventDefinition) =>
                {
                    Assert.AreEqual(expectedEvent.EventDefinitionId, eventDefinition.EventDefinitionId);
                    Assert.IsNull(expectedEvent.MapImage);
                    called = true;
                },
                GetByIdInt32 = (id) =>
                {
                    Assert.IsTrue(id == expectedEvent.EventDefinitionId);
                    return expectedEvent;
                }
            };

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

                var target = new RoomPointsController(eventDefinitionService);

                target.PutRoomImage(expectedEvent);

                Assert.IsTrue(called);
            }
        }
コード例 #8
0
        public void PostRoomPoints_NotFail_Test()
        {
            bool called = false;
            var expected =
                new List<RoomPoint>() {
                    new RoomPoint() { EventDefinitionId = 1 },
                    new RoomPoint() { EventDefinitionId = 1 },
                    new RoomPoint() { EventDefinitionId = 1 } };

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                AddRoomPointsIEnumerableOfRoomPoint = (roomPoints) =>
                {
                    Assert.AreEqual(expected.Count(), roomPoints.Count());
                    called = true;
                },
                GetByIdInt32 = (id) =>
                {
                    Assert.IsTrue(id == 1);
                    return new EventDefinition() { OrganizerId = 1 };
                }
            };

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

                var target = new RoomPointsController(eventDefinitionService);

                target.PostRoomPoints(expected);

                Assert.IsTrue(called);
            }
        }
コード例 #9
0
        public void GetRoomImage_NotFail_Test()
        {
            bool called = false;
            var expectedEventId = 1;

            IEventDefinitionRepository eventDefinitionService = new StubIEventDefinitionRepository()
            {
                GetRoomImageInt32 = (eventId) =>
                {
                    Assert.AreEqual(expectedEventId, eventId);
                    called = true;
                    return null;
                }
            };

            var target = new RoomPointsController(eventDefinitionService);

            var result = target.GetRoomImage(expectedEventId);

            Assert.IsTrue(called);
            Assert.IsNull(result);
        }