예제 #1
0
        public IActionResult RemoveGroupsFavourite([FromQuery] string slug, [FromQuery] string type)
        {
            switch (type)
            {
            case "group":
                _cookiesHelper.RemoveFromCookies <Group>(slug, "favourites");
                break;

            case "event":
                _cookiesHelper.RemoveFromCookies <Event>(slug, "favourites");
                break;
            }

            return(new OkResult());
        }
예제 #2
0
        public void ShouldRemoveFromFavouritesCollection()
        {
            // Arrange
            var cookies = new FakeCookie(true);

            httpContextAccessor.Setup(_ => _.HttpContext.Request.Cookies).Returns(cookies);
            httpContextAccessor.Setup(_ => _.HttpContext.Response.Cookies).Returns(cookies);

            // Act
            cookiesHelper.RemoveFromCookies <Group>("foo", "favourites");
            cookiesHelper.RemoveFromCookies <Group>("bar", "favourites");
            var result = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(cookies["favourites"]);

            // Assert
            result[typeof(Group).ToString()].Should().Equal(@"test1");
        }