コード例 #1
0
        public void TestReviewsById(int id, int expResult)
        {
            List <Movie> movies = new List <Movie>()
            {
                new Movie {
                    Reviewer = 1
                },
                new Movie {
                    Reviewer = 1
                },
                new Movie {
                    Reviewer = 2
                },
                new Movie {
                    Reviewer = 2
                },
                new Movie {
                    Reviewer = 3
                },
            };
            MovieSystem ms     = new MovieSystem(movies);
            int         result = ms.ReviewsById(id);

            Assert.Equal(result, expResult);
        }
        public void PerformanceTestReviewsById()
        {
            MovieSystem _ms       = new MovieSystem("ratings.json");
            var         stopwatch = new Stopwatch();
            int         id        = 3;

            stopwatch.Start();
            _ms.ReviewsById(id);
            stopwatch.Stop();

            var  stop         = stopwatch.ElapsedMilliseconds;
            long expectedTime = 4000;

            Assert.True(stop <= expectedTime);
        }
コード例 #3
0
        public void TestExceptionThrownByReviewsById(int reviewer)
        {
            List <Movie> movies = new List <Movie>()
            {
                new Movie {
                    Reviewer = 1
                },
                new Movie {
                    Reviewer = 1
                },
                new Movie {
                    Reviewer = 2
                },
                new Movie {
                    Reviewer = 2
                },
                new Movie {
                    Reviewer = 3
                }
            };
            MovieSystem ms = new MovieSystem(movies);

            Assert.Throws <InvalidDataException>(() => ms.ReviewsById(reviewer));
        }