public void Cannot_Delete_Non_Existed_User_From_Project()
        {
            //Arrange

            var eventBusMock = new Mock <IEventBus>();
            var tempDataMock = new Mock <ITempDataDictionary>();

            var userRepositoryMock = new Mock <IUserRepository>();

            userRepositoryMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(() => null);

            var factoryMock = new Mock <IDeleteByIdUserFactory>();

            factoryMock.Setup(m => m.Create())
            .Returns(new DeleteByIdUser(userRepositoryMock.Object, eventBusMock.Object));

            //Act

            var target = new ProjectsController(eventWatcher.Object, logger.Object, eventBus.Object,
                                                factoryMock.Object, null, null,
                                                null, null, null, null, null, null, null);

            target.TempData = tempDataMock.Object;

            var targetView = target.DeleteUserFromProject(1, 1);

            //Assert

            Assert.True(targetView.StatusCode == HttpStatusCode.InternalServerError);
        }
        public void Can_Delete_User_From_Project()
        {
            var user = new User
            {
                Id           = 1,
                Login        = "******",
                ProjectUsers = new List <ProjectUser>
                {
                    new ProjectUser {
                        ProjectId = 1
                    }
                },
                Status = UserStatus.Active
            };
            var eventBusMock       = new Mock <IEventBus>();
            var tempDataMock       = new Mock <ITempDataDictionary>();
            var userRepositoryMock = new Mock <IUserRepository>();

            userRepositoryMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(user);

            var factoryMock = new Mock <IDeleteByIdUserFactory>();

            factoryMock.Setup(m => m.Create())
            .Returns(new DeleteByIdUser(userRepositoryMock.Object, eventBusMock.Object));

            //Act

            var target = new ProjectsController(eventWatcher.Object, logger.Object, eventBus.Object,
                                                factoryMock.Object, null, null,
                                                null, null, null, null, null, null, null);

            target.TempData = tempDataMock.Object;

            var targetView = target.DeleteUserFromProject(1, 1);

            //Assert

            userRepositoryMock.Verify(m => m.Edit(It.IsAny <User>()));
            Assert.True(targetView.StatusCode == HttpStatusCode.NoContent);
            Assert.True(user.Status == UserStatus.Active);
        }