Ejemplo n.º 1
0
    public void CreateData()
    {
        this.db = new Mock <AuctionContext>(); // creates the virtual database

        this.zipController = new ZipControllerMock(this.db.Object);

        var zip = GetZipFromDb();

        var data = new List <Zip> {
            zip
        };

        this.mockSet = new Mock <DbSet <Zip> >().SetupData(data); // prepare the virtual zip

        this.db.Setup(z => z.Zips).Returns(this.mockSet.Object);
    }
Ejemplo n.º 2
0
        public void Initialize()
        {
            // Arrange

            //setting dependency injection for the tests
            db                = new Mock <AuctionContext>();
            bidController     = new BidControllerMock(db.Object);
            userController    = new UserControllerMock(db.Object);
            zipController     = new ZipControllerMock(db.Object);
            productController = new ProductControllerMock(db.Object);

            // this.data = new List<Product>() { availableProduct, unavailableProduct }; // insert in collection

            products = new List <Product>()
            {
                GetProduct()
            };
            zips = new List <Zip>()
            {
                GetZip()
            };
            users = new List <User>()
            {
                GetUser(), GetUser2()
            };
            bids = GetBids();

            //Seting up the mocked DB

            mockSetBid     = new Mock <DbSet <Bid> >().SetupData(bids);
            mockSetUser    = new Mock <DbSet <User> >().SetupData(users);
            mockSetZip     = new Mock <DbSet <Zip> >().SetupData(zips);
            mockSetProduct = new Mock <DbSet <Product> >().SetupData(products);

            db.Setup(m => m.Bids).Returns(mockSetBid.Object);
            db.Setup(m => m.Users).Returns(mockSetUser.Object);
            db.Setup(m => m.Zips).Returns(mockSetZip.Object);
            db.Setup(m => m.Products).Returns(mockSetProduct.Object);
        }