public void ComputesLowestRate()
        {
            RatingBook book = new RatingBook();

            book.AddRating(19);
            book.AddRating(89);

            RatingStats result = book.CalculateStats();

            Assert.AreEqual(19, result.LowestGrade);
        }
        public void ReferenceTypesPassByValue()
        {
            RatingBook book1 = new RatingBook();
            RatingBook book2 = book1; // this line of code is copying the reference that is inside of book1 into book2

            // So now we have two variables pointing to the same object

            GiveBookAName(book2);
            Assert.AreEqual("My Grade Book", book1.Name);
            // test passed because the value inside of book2 is copied into the parameter book and that value is a pointer
            // Any changes that we make to the RatingBook through any of those variables they will be visible through any of the other variables
        }
        public void ComputesAvegareGrade()
        {
            RatingBook book = new RatingBook();

            book.AddRating(56);
            book.AddRating(89.5f);
            book.AddRating(23);

            RatingStats result = book.CalculateStats();

            // Assertion made for float numbers
            Assert.AreEqual(56.16, result.AverageGrade, 0.01);
        }
        public void ComputesHighestRate()
        {
            // Establish a reference from Tests Project to the main Project
            // Set the protection level right so you can create a RatingBook object
            RatingBook book = new RatingBook();

            book.AddRating(50);
            book.AddRating(70);

            RatingStats result = book.CalculateStats();

            Assert.AreEqual(70, result.HighestGrade);
            // What if someone changes the code inside CalculateStats. The developer will know cause the test will fail.
        }
        public void VariablesHoldAReference()
        {
            // Part 2 - References
            RatingBook r1 = new RatingBook();
            // The value that is inside of r1 variable is going to be a pointer
            RatingBook r2 = r1;

            // Now we have two variables pointing to the exact same object
            // what if ...
            // r1 = new RatingBook();
            r1.Name = "My Rating Book";
            Assert.AreEqual(r1.Name, r2.Name);
            // We will do some testing in the unit tests about reference types
        }
        private static XElement CreateBookReviewItem(int idValue, int idBookValue, RatingBook ratingValue, bool isFavouriteValue, string commentValue)
        {
            XElement id = new XElement(BookRepository.BookReviewsID, idValue);
            XElement bookId = new XElement(BookRepository.BookReviewsBookID, idBookValue);
            XElement rating = new XElement(BookRepository.BookReviewsRating, ratingValue.ToString());
            XElement isFavourite = new XElement(BookRepository.BookReviewsIsFavourite, isFavouriteValue.ToString());
            XElement comment = new XElement(BookRepository.BookReviewsComment, commentValue);

            XElement bookReview = new XElement(BookRepository.BookReviewsElement, id, bookId, comment, isFavourite, rating);

            return bookReview;
        }
 // This method takes a RatingBook parameter
 private void GiveBookAName(RatingBook book)
 {
     book.Name = "My Grade Book";
 }