Esempio n. 1
0
        public void InvoiceBLLCount()
        {
            var data = new List <Invoice>
            {
                new Invoice()
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Invoice> >();

            mockSet.As <IQueryable <Invoice> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Invoice> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Invoice> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Invoice> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <OfficeStoreContext>();

            mockContext.Setup(c => c.Invoice).Returns(mockSet.Object);

            var service = new InvoiceBLL(mockContext.Object);

            Assert.IsTrue(service.InvoiceCount() == 1);
        }