Exemplo n.º 1
0
        public ParksControllerTests()
        {
            var myProfile     = new ParkProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));

            _parks = GetTestParks();

            var httpContext = new DefaultHttpContext();

            _tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            _mockService     = new Mock <IParksService>();
            _mockSortService = new Mock <ISortingService>();

            _mockUser = new Mock <ClaimsPrincipal>();
            _mockUser.Setup(s => s.AddIdentity(new ClaimsIdentity(
                                                   new Claim[]
            {
                new Claim(ClaimTypes.Name, "mock"),
                new Claim(ClaimTypes.NameIdentifier, "1")
            }, "mock")));
        }
        public ParkEventsControllerTests()
        {
            var myProfile     = new ParkProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));

            _events = GetTestParkEvents();
            _parks  = GetTestParks();

            var httpContext = new DefaultHttpContext();

            _tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            _mockAuthService       = new Mock <IAuthenticationService>();
            _mockService           = new Mock <IParkEventsService>();
            _mockSortService       = new Mock <ISortingService>();
            _mockSelectListService = new Mock <ISelectListService>();

            _mockUser = new Mock <ClaimsPrincipal>();
            _mockUser.Setup(s => s.AddIdentity(new ClaimsIdentity(
                                                   new Claim[]
            {
                new Claim(ClaimTypes.Name, "mock"),
                new Claim(ClaimTypes.NameIdentifier, "1")
            }, "mock")));

            _mockAuthService.Setup(s => s.IsSignedInAsync(_mockUser.Object))
            .ReturnsAsync(true);

            _mockSelectListService.Setup(s => s.GetParkSelectListItemsAsync <ParkEventModel>(true))
            .ReturnsAsync(_parks.Where(p => p.Events.Any())
                          .Select(p => new SelectListItem
            {
                Selected = false,
                Text     = p.Name,
                Value    = p.ParkId.ToString()
            }));
        }