public void Add_RentalAsset_To_Db()
        {
            var mockDbset   = new Mock <DbSet <RentalAsset> >();
            var mockContext = new Mock <RentalContext>();

            mockContext.Setup(r => r.RentalAssets).Returns(mockDbset.Object);

            var service = new RentalAssetService(mockContext.Object);

            service.Add(new Guitar());

            mockContext.Verify(a => a.Add(It.IsAny <RentalAsset>()), Times.Once);
            mockContext.Verify(s => s.SaveChanges(), Times.Once);
        }
        public void Get_RentalAsset_Stock()
        {
            var inv = GetInventories().AsQueryable();

            var mockDbSet = new Mock <DbSet <Inventory> >();

            mockDbSet.As <IQueryable <Inventory> >().Setup(p => p.Provider).Returns(inv.Provider);
            mockDbSet.As <IQueryable <Inventory> >().Setup(p => p.Expression).Returns(inv.Expression);
            mockDbSet.As <IQueryable <Inventory> >().Setup(p => p.ElementType).Returns(inv.ElementType);
            mockDbSet.As <IQueryable <Inventory> >().Setup(p => p.GetEnumerator()).Returns(inv.GetEnumerator);

            var mockContext = new Mock <RentalContext>();

            mockContext.Setup(r => r.Inventory).Returns(mockDbSet.Object);

            var service = new RentalAssetService(mockContext.Object);
            var price   = service.GetStock(3);

            price.Should().Be(16);
        }
        public void Get_RentalAsset_Availability()
        {
            var assets = GetRentalAssets().AsQueryable();
            var asset  = assets.FirstOrDefault(a => a.Id == 4);

            var mockDbSet = new Mock <DbSet <RentalAsset> >();

            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.Provider).Returns(assets.Provider);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.Expression).Returns(assets.Expression);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.ElementType).Returns(assets.ElementType);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.GetEnumerator()).Returns(assets.GetEnumerator);

            var mockContext = new Mock <RentalContext>();

            mockContext.Setup(r => r.RentalAssets).Returns(mockDbSet.Object);

            var service = new RentalAssetService(mockContext.Object);
            var avail   = service.GetAvailable(asset.Id);

            avail.Should().BeFalse();
        }
        public void Get_RentalAsset_Description()
        {
            var assets = GetRentalAssets().AsQueryable();
            var asset  = assets.FirstOrDefault(a => a.Id == 1);

            var mockDbSet = new Mock <DbSet <RentalAsset> >();

            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.Provider).Returns(assets.Provider);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.Expression).Returns(assets.Expression);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.ElementType).Returns(assets.ElementType);
            mockDbSet.As <IQueryable <RentalAsset> >().Setup(p => p.GetEnumerator()).Returns(assets.GetEnumerator);

            var mockContext = new Mock <RentalContext>();

            mockContext.Setup(r => r.RentalAssets).Returns(mockDbSet.Object);

            var service = new RentalAssetService(mockContext.Object);
            var desc    = service.GetDescription(asset.Id);

            desc.Should().Be("Neat");
        }