Ejemplo n.º 1
0
        private void UpdateClub()
        {
            try
            {
                User objUser = UsersController.GetUserByIDForClubs(UserId);

                // update Club detail
                Club objClub = ClubController.GetClubsByID(objUser.ClubId);
                objClub.clubName = txtClubName.Text;
                objClub.isActive = chkIsActive.Checked;
                new ClubController().UpdateClub(objClub);

                //update User details
                objUser.FirstName = txtFirstName.Text;
                objUser.LastName  = txtLastName.Text;
                objUser.Mobile    = txtMobileNumber.Text;
                objUser.Email     = txtEmail.Text;
                objUser.UserName  = txtUserName.Text;
                objUser.Password  = txtPassword.Text;
                objUser.Address1  = txtAdress.Text;
                objUser.isActive  = chkIsActive.Checked;

                new UsersController().UpdateUser(objUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public async Task GetAllClub()
        {
            try
            {
                // Arrange
                ClubController controller = new ClubController();
                controller.Request = new HttpRequestMessage();
                controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
                // Act
                ClubProvider _ClubProvider = new ClubProvider();
                var          testProducts  = await _ClubProvider.GetAll() as List <Club>;

                int testproduct = testProducts.Count;
                // Act
                var response = await controller.GetClub() as HttpResponseMessage;

                ObjectContent objContent   = response.Content as ObjectContent;
                List <Club>   picklistItem = objContent.Value as List <Club>;
                int           icount       = picklistItem.Count;
                // Assert
                Assert.IsNotNull(response);
                Assert.AreEqual(testproduct, icount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public ClubControllerTests()
        {
            _mapper = new Mock <IMapper>();
            var loggerService = new Mock <ILoggerService <ClubController> >();

            _clubService               = new Mock <IClubService>();
            _clubMembersService        = new Mock <IClubMembersService>();
            _clubAdministrationService = new Mock <IClubAdministrationService>();

            var user = new UserDTO();

            _userManagerService = new Mock <IUserManagerService>();
            _userManagerService.Setup(x => x.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(user);
            _userManagerService.Setup(x => x.GetRolesAsync(It.IsAny <UserDTO>())).ReturnsAsync(new List <string>());
            _userManagerService.Setup(x => x.GetUserIdAsync(It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(It.IsAny <string>());

            controller = new ClubController(_clubService.Object,
                                            _clubAdministrationService.Object,
                                            _clubMembersService.Object,
                                            _mapper.Object,
                                            loggerService.Object,
                                            _userManagerService.Object);

            var context  = new Mock <HttpContext>();
            var identity = new GenericIdentity("username");

            identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "1"));
            var principal = new GenericPrincipal(identity, new[] { "user" });

            context.Setup(s => s.User).Returns(principal);
            controller.ControllerContext.HttpContext = context.Object;
        }
Ejemplo n.º 4
0
        public async Task GetCities_Valid_Test(int page, int pageSize, string cityName)
        {
            // Arrange
            ClubController clubcon     = CreateClubController;
            var            httpContext = new Mock <HttpContext>();

            httpContext
            .Setup(m => m.User.IsInRole(Roles.Admin))
            .Returns(true);
            var context = new ControllerContext(
                new ActionContext(
                    httpContext.Object, new RouteData(),
                    new ControllerActionDescriptor()));

            clubcon.ControllerContext = context;
            _ClubService
            .Setup(c => c.GetAllDtoAsync(It.IsAny <string>()))
            .ReturnsAsync(GetClubsBySearch());

            // Act
            var result = await clubcon.GetClubs(page, pageSize, cityName);

            // Assert
            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
            Assert.IsNotNull(((result as ObjectResult).Value as ClubsViewModel)
                             .Clubs.Where(c => c.Name.Equals("Курінь")));
        }
Ejemplo n.º 5
0
        public async Task GetClubById()
        {
            try
            {
                // Arrange
                ClubController controller = new ClubController();
                controller.Request = new HttpRequestMessage();
                controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
                // Act
                ClubProvider _ClubProvider = new ClubProvider();
                var          testClub      = await _ClubProvider.GetById(1) as Club;

                // Act
                var response = await controller.GetClub(1) as HttpResponseMessage;

                ObjectContent objContent = response.Content as ObjectContent;
                var           pickClub   = objContent.Value as Club;
                // Assert
                Assert.IsNotNull(response);
                Assert.AreEqual(testClub, pickClub);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        public void EditClubTest()
        {
            // arrange
            var controller = new ClubController(repository.Object, usermanager.Object, hostingEnvironment.Object);
            var mockFile   = new Mock <IFormFile>();

            repository.Setup(r => r.Club.FindByCondition(It.IsAny <Expression <Func <Club, bool> > >())).Returns(
                new List <Club>
            {
                new Club {
                    ClubName    = "Club 2",
                    Description = "Some text"
                }
            }.AsQueryable());
            var expected = new Club
            {
                ClubName    = "Club 2",
                Description = "Some text"
            };
            // action
            var viewModel = new ClubViewModel {
                Club = expected
            };
            var result = controller.EditClub(viewModel, mockFile.Object);

            // assert
            repository.Verify(r => r.Club.Update(It.IsAny <Club>()), Times.Once());
        }
Ejemplo n.º 7
0
        public void GetTest()
        {
            ClubController con      = new ClubController();
            var            response = con.Get();

            Assert.AreEqual(response.StatusCode, System.Net.HttpStatusCode.OK);
        }
Ejemplo n.º 8
0
 public GetForGridTests()
 {
     _nombrePrimerClubSegunOrdenAlfabetico = "Boca";
     _nombreUltimoClubSegunOrdenAlfabetico = "Velez";
     _clubController        = new ClubController();
     _torneoController      = new TorneoController();
     _totalDeClubesEnLaBase = Context.Clubs.Count();
 }
Ejemplo n.º 9
0
 public GestionOrganisateur()
 {
     oc = new OrganisateurController();
     cl = new ClubController();
     ce = new CentreController();
     av = new Agence_VoyageController();
     InitializeComponent();
 }
        public void Index_ShouldReturnView()
        {
            ClubController controller = new ClubController(userManager.Object);

            var result = controller.Index();

            Assert.IsAssignableFrom <ViewResult>(result);
        }
Ejemplo n.º 11
0
        private void PopulateClubDropDown()
        {
            ClubController controller = new ClubController();

            DisplayClubs.DataSource     = controller.Club_List();
            DisplayClubs.DataTextField  = nameof(Club.ClubID);
            DisplayClubs.DataValueField = nameof(Club.ClubID);
            DisplayClubs.DataBind();
            DisplayClubs.Items.Insert(0, new ListItem("[Select a club]"));
        }
Ejemplo n.º 12
0
        public void ChangeIsApprovedStatusFollowersTest()
        {
            ChangeIsApprovedStatusRepositorySetup();
            //action
            var controller = new ClubController(repository.Object, usermanager.Object, hostingEnvironment.Object);
            var result     = controller.ChangeIsApprovedStatusFollowers(1, 1);

            // assert
            repository.Verify(r => r.ClubMembers.Update(It.IsAny <ClubMembers>()), Times.Once());
        }
Ejemplo n.º 13
0
        public async Task Remove_Valid_Test()
        {
            _ClubService.Setup(c => c.RemoveAsync(It.IsAny <int>()));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.Remove(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkResult>(result);
        }
Ejemplo n.º 14
0
        public async Task GetClubThatUserHasAccessTo_Valid_Test()
        {
            _ClubAccessService.Setup(c => c.GetClubsAsync(It.IsAny <ClaimsPrincipal>()));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.GetClubsThatUserHasAccessTo();

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 15
0
        public async Task GetPhotoBase64_Valid_Test(string logoName)
        {
            _ClubService.Setup(c => c.GetLogoBase64(It.IsAny <string>()))
            .ReturnsAsync(new string("some string"));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.GetPhotoBase64(logoName);

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 16
0
        public async Task GetProfile_Invalid_Test()
        {
            _ClubService.Setup(c => c.GetClubProfileAsync(It.IsAny <int>(), It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(() => null);

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.GetProfile(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
Ejemplo n.º 17
0
 private void BindGrid()
 {
     try
     {
         grdClubs.DataSource = ClubController.GetClubs(txtSearchText.Text, SortField, SortDir);
         grdClubs.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 18
0
        public void EditClubTestWithoutClubName()
        {
            // arrange
            var controller = new ClubController(repository.Object, usermanager.Object, hostingEnvironment.Object);
            var mockFile   = new Mock <IFormFile>();
            // action
            var viewModel = new ClubViewModel();
            var result    = controller.EditClub(viewModel, mockFile.Object);

            // assert
            Assert.IsType <RedirectToActionResult>(result);
        }
Ejemplo n.º 19
0
        public async Task RemoveFollower_Valid_Test()
        {
            _ClubParticipantsService.Setup(c => c.RemoveFollowerAsync(It.IsAny <int>()));

            _logger.Setup(l => l.LogInformation(It.IsAny <string>()));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.RemoveFollower(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkResult>(result);
        }
Ejemplo n.º 20
0
        public async Task AddFollower_Valid_Test()
        {
            _ClubParticipantsService.Setup(c => c.AddFollowerAsync(It.IsAny <int>(), It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(new ClubMembersDTO());

            _logger.Setup(l => l.LogInformation(It.IsAny <string>()));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.AddFollower(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 21
0
        public void CreateReturnsClub()
        {
            //Arrange
            var mockRepo      = new Mock <IUnitOfWork>();
            var mapper        = new Mock <IMapper>();
            var controller    = new ClubController(mapper.Object, mockRepo.Object);
            var createClubDto = new CreateClubDto();

            //Act
            var result = controller.Create(createClubDto);

            //Assert
            Assert.IsAssignableFrom <Task <IActionResult> >(result);
        }
Ejemplo n.º 22
0
        public void GetReturnsClubs()
        {
            //Arrange
            var mockRepo   = new Mock <IUnitOfWork>();
            var mapper     = new Mock <IMapper>();
            var clubParams = new ClubParams();
            var controller = new ClubController(mapper.Object, mockRepo.Object);

            //Act
            var result = controller.GetClubs(clubParams);

            //Assert
            Assert.IsAssignableFrom <Task <ActionResult <PagedList <ClubDto> > > >(result);
        }
Ejemplo n.º 23
0
        public async Task ChangeApproveStatus_Valid_Test()
        {
            _ClubParticipantsService.Setup(c => c.ToggleApproveStatusAsync(It.IsAny <int>()))
            .ReturnsAsync(new ClubMembersDTO());

            _logger.Setup(l => l.LogInformation(It.IsAny <string>()));

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.ChangeApproveStatus(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 24
0
        public void IndexTest()
        {
            //arrange
            repository.Setup(c => c.Club.FindByCondition(It.IsAny <Expression <Func <Club, bool> > >())).Returns(GetTestClubs());

            //action
            var controller = new ClubController(repository.Object, usermanager.Object, hostingEnvironment.Object);
            var result     = controller.Index();

            //assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.IsAssignableFrom <List <ClubViewModel> >(viewResult.Model);
        }
Ejemplo n.º 25
0
        public void GetReturnsClub()
        {
            //Arrange
            var mockRepo   = new Mock <IUnitOfWork>();
            var mapper     = new Mock <IMapper>();
            var controller = new ClubController(mapper.Object, mockRepo.Object);
            var clubId     = 1;

            //Act
            var result = controller.GetClub(clubId);

            //Assert
            Assert.IsAssignableFrom <Task <IActionResult> >(result);
        }
Ejemplo n.º 26
0
        public void should_return_expected_club(string path, string expectedClub)
        {
            var httpContext = A.Fake <HttpContextBase>();

            A.CallTo(() => httpContext.Request.AppRelativeCurrentExecutionFilePath).Returns(path);
            A.CallTo(() => httpContext.Request.Url).Returns(new Uri("http://localhost/" + path.Replace("~/", string.Empty)));
            var routeData = RouteTable.Routes.GetRouteData(httpContext);

            Assert.IsNotNull(routeData);
            var currentClub = ClubController.GetCurrentClub(httpContext, routeData);

            Assert.IsNotNull(currentClub);
            Assert.AreEqual(expectedClub, currentClub.ShortName);
        }
Ejemplo n.º 27
0
        public async Task GetClubNameOfApprovedMemberTest()
        {
            //Arrange
            _ClubParticipantsService
            .Setup(c => c.ClubOfApprovedMember(It.IsAny <string>()));
            ClubController Clubcon = CreateClubController;

            //Act
            var result = await Clubcon.ClubNameOfApprovedMember(GetStringFakeId());

            //Assert
            Assert.NotNull(result);
            Assert.IsInstanceOf <OkObjectResult>(result);
        }
Ejemplo n.º 28
0
        public async Task Details_Invalid_Test()
        {
            _ClubService.Setup(c => c.GetByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(() => null);

            _mapper.Setup(m => m.Map <ClubDTO, ClubViewModel>(It.IsAny <ClubDTO>()))
            .Returns(new ClubViewModel());

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.Details(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
Ejemplo n.º 29
0
        public async Task GetProfile_Invalid_Test(int id)
        {
            _ClubService.Setup(c => c.GetClubProfileAsync(It.IsAny <int>(), It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(() => null);

            _mapper.Setup(m => m.Map <ClubProfileDTO, ClubViewModel>(It.IsAny <ClubProfileDTO>()))
            .Returns(new ClubViewModel());

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.GetProfile(id);

            Assert.NotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
Ejemplo n.º 30
0
        public async Task GetDocumentsInvalidCheck()
        {
            _ClubService.Setup(c => c.GetClubDocumentsAsync(It.IsAny <int>()))
            .ReturnsAsync(() => null);

            _mapper.Setup(m => m.Map <ClubProfileDTO, ClubViewModel>(It.IsAny <ClubProfileDTO>()))
            .Returns(new ClubViewModel());

            ClubController Clubcon = CreateClubController;

            var result = await Clubcon.GetDocuments(GetFakeID());

            Assert.NotNull(result);
            Assert.IsInstanceOf <NotFoundResult>(result);
        }