Esempio n. 1
0
        public void TestDeleteOneIDOutOfRange()
        {
            //Arrange
            SessionsController controller = new SessionsController();

            //Act
            StatusCodeResult response = (StatusCodeResult)controller.Delete(8);

            //Assert
            Assert.AreEqual(response.StatusCode, StatusCodes.Status404NotFound);
        }
Esempio n. 2
0
        public void TestDeleteOne()
        {
            //Arrange
            SessionsController controller = new SessionsController();

            //Act
            StatusCodeResult response = (StatusCodeResult)controller.Delete(46);

            //Assert
            Assert.AreEqual(response.StatusCode, 200);
        }
        public void DeleteSession_NotFail_Test()
        {
            bool called          = false;
            var  expectedSession = new Session()
            {
                SessionId = 1, EventDefinitionId = 1
            };

            var eventDefinition = new EventDefinition()
            {
                OrganizerId = 1
            };
            IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository()
            {
                GetByIdInt32 = (id) =>
                {
                    Assert.AreEqual(expectedSession.EventDefinitionId, id);
                    return(eventDefinition);
                }
            };

            ISessionRepository sessionRepository = new StubISessionRepository()
            {
                DeleteInt32 = sessionId =>
                {
                    Assert.AreEqual(expectedSession.SessionId, sessionId);
                    called = true;
                },
                GetInt32 = (sessionId) =>
                {
                    Assert.AreEqual(expectedSession.SessionId, sessionId);
                    return(expectedSession);
                }
            };

            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.Delete(expectedSession.SessionId);

                Assert.IsTrue(called);
            }
        }
Esempio n. 4
0
        public void Sessions_Controller_Should_Remove_Sucessfully()
        {
            // Arrange
            var isUpdated  = true;
            int idToRemove = 1;

            _sessionServiceMock.Setup(c => c.Remove(It.IsAny <long>())).Returns(isUpdated);

            // Action
            IHttpActionResult callback = _sessionsController.Delete(idToRemove);

            // Assert
            var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject;

            _sessionServiceMock.Verify(s => s.Remove(idToRemove), Times.Once);
            httpResponse.Content.Should().BeTrue();
        }