コード例 #1
0
        public void GetUserDislikedJokesIdList_Must_Return_Id_List_Of_User_Liked_Jokes()
        {
            // Arrange
            var dbContext = StaticMethods.GetDb();

            dbContext.Database.EnsureDeleted();
            var jokesService = new JokesService(dbContext, mapper);
            var testUser     = StaticMethods.GetTestUser();
            var testJokeBM   = GetTestJokeBM();

            //Act
            dbContext.Users.Add(testUser);
            dbContext.SaveChanges();
            var Joke1      = jokesService.AddJoke(testJokeBM, testUser);
            var Joke2      = jokesService.AddJoke(testJokeBM, testUser);
            var Joke3      = jokesService.AddJoke(testJokeBM, testUser);
            var ratedJoke1 = GetTestJokeRatedDownBM(Joke1.Id, testUser.UserName);
            var ratedJoke2 = GetTestJokeRatedDownBM(Joke2.Id, testUser.UserName);
            var ratedJoke3 = GetTestJokeRatedDownBM(Joke3.Id, testUser.UserName);

            jokesService.RateJoke(ratedJoke1, testUser);
            jokesService.RateJoke(ratedJoke2, testUser);
            jokesService.RateJoke(ratedJoke3, testUser);

            var result = jokesService.GetUserDislikedJokesIdList(testUser.Id);

            //Assert
            Assert.True(result.Contains(Joke1.Id));
            Assert.True(result.Contains(Joke2.Id));
            Assert.True(result.Contains(Joke3.Id));
        }
コード例 #2
0
        public void GetUserDislikedJokesIdList_Must_Return_Empty_Collection_If_User_Havent_Disliked_Any_Joke()
        {
            // Arrange
            var dbContext    = StaticMethods.GetDb();
            var jokesService = new JokesService(dbContext, mapper);
            var testUser     = StaticMethods.GetTestUser();
            var testJokeBM   = GetTestJokeBM();

            //Act
            dbContext.Users.Add(testUser);
            dbContext.SaveChanges();
            var addedJoke = jokesService.AddJoke(testJokeBM, testUser);
            var result    = jokesService.GetUserDislikedJokesIdList(testUser.Id);

            //Assert
            Assert.True(result.Count == 0);
        }