public void ReturnsBarsCount_WhenItIsLessThanThePassedParameter()
        {
            //Arrange
            var bars = new List <ShishaBar>()
            {
                new ShishaBar()
                {
                    RatingValue = 1.3
                },
                new ShishaBar()
                {
                    RatingValue = 4.6
                }
            }.AsQueryable();
            var mockedBarsRepo = new Mock <IEntityFrameworkRepository <ShishaBar> >();

            mockedBarsRepo.Setup(x => x.All).Returns(bars);
            var mockedData = new Mock <IShishaTimeData>();

            mockedData.Setup(x => x.Bars).Returns(mockedBarsRepo.Object);
            var service = new BarsService(mockedData.Object);

            //Act
            var result = service.GetTopRated(3);

            //Arrange
            Assert.IsTrue(result.Count() == 2);
        }
        public void CallDataBarsRepo_AllProperty()
        {
            //Arrange
            var bars           = new List <ShishaBar>().AsQueryable();
            var mockedBarsRepo = new Mock <IEntityFrameworkRepository <ShishaBar> >();

            mockedBarsRepo.Setup(x => x.All).Returns(bars);
            var mockedData = new Mock <IShishaTimeData>();

            mockedData.Setup(x => x.Bars).Returns(mockedBarsRepo.Object);
            var service = new BarsService(mockedData.Object);

            //Act
            service.GetTopRated(3);

            //Arrange
            mockedBarsRepo.Verify(x => x.All, Times.Once());
        }
        public void SortTheReturnedBarsByRating()
        {
            //Arrange
            var bars = new List <ShishaBar>()
            {
                new ShishaBar()
                {
                    RatingValue = 4.9
                },
                new ShishaBar()
                {
                    RatingValue = 2.0
                },
                new ShishaBar()
                {
                    RatingValue = 3.6
                },
                new ShishaBar()
                {
                    RatingValue = 1.3
                },
                new ShishaBar()
                {
                    RatingValue = 4.6
                }
            }.AsQueryable();
            var mockedBarsRepo = new Mock <IEntityFrameworkRepository <ShishaBar> >();

            mockedBarsRepo.Setup(x => x.All).Returns(bars);
            var mockedData = new Mock <IShishaTimeData>();

            mockedData.Setup(x => x.Bars).Returns(mockedBarsRepo.Object);
            var service = new BarsService(mockedData.Object);

            //Act
            var result   = service.GetTopRated(3);
            var expected = result.OrderByDescending(x => x.RatingValue).ToList();

            //Arrange
            Assert.AreEqual(expected, result);
            Assert.AreEqual(4.9, result.First().RatingValue);
            Assert.AreEqual(3.6, result.Last().RatingValue);
        }
        public void ReturnsCorrectNumberOfBars()
        {
            //Arrange
            var bars = new List <ShishaBar>()
            {
                new ShishaBar()
                {
                    RatingValue = 4.9
                },
                new ShishaBar()
                {
                    RatingValue = 2.0
                },
                new ShishaBar()
                {
                    RatingValue = 3.6
                },
                new ShishaBar()
                {
                    RatingValue = 1.3
                },
                new ShishaBar()
                {
                    RatingValue = 4.6
                }
            }.AsQueryable();
            var mockedBarsRepo = new Mock <IEntityFrameworkRepository <ShishaBar> >();

            mockedBarsRepo.Setup(x => x.All).Returns(bars);
            var mockedData = new Mock <IShishaTimeData>();

            mockedData.Setup(x => x.Bars).Returns(mockedBarsRepo.Object);
            var service = new BarsService(mockedData.Object);

            //Act
            var result = service.GetTopRated(3);

            //Arrange
            Assert.IsTrue(result.Count() == 3);
        }