示例#1
0
        public void MockEdit()
        {
            var customerDbSetMock =
                new Mock <DbSet <Customer> >();

            var webContextMock =
                new Mock <WebContextDb>();

            webContextMock.Setup(m => m.Set <Customer>()).
            Returns(customerDbSetMock.Object);

            webContextMock.Setup(m => m.Set <Customer>()).
            Returns(customerDbSetMock.Object);

            var repository =
                new BaseRepositorio <Customer>(webContextMock.Object);

            //customerMockList();

            var newcustomer = TestcustomerOk();

            repository.Agregar(newcustomer);
            // customerDbSetMock.Verify(p => p.Add(It.IsAny<customer>()), Times.Once);
            var customerGetByID = repositorio
                                  .GetById(p => p.FirstName == "Name1");

            //      var customerToUpdate = repository.GetById(x => x.FirstName == "Name1");
            webContextMock.Verify(w => w.SaveChanges(), Times.Once);
        }
示例#2
0
        public void MockData()
        {
            var customerDbSetMock =
                new Mock <DbSet <Customer> >();
            //new Mock<DbSet<customer>> ();

            var webContextMock =
                new Mock <WebContextDb>();

            webContextMock.Setup(m => m.Set <Customer>()).
            Returns(customerDbSetMock.Object);

            webContextMock.Setup(m => m.Set <Customer>()).
            Returns(customerDbSetMock.Object);

            var repositorio =
                new BaseRepositorio <Customer>(webContextMock.Object);

            var newcustomer = TestcustomerOk();

            repositorio.Agregar(newcustomer);
            customerDbSetMock.Verify(p => p.Add(It.IsAny <Customer>()), Times.Once);
            webContextMock.Verify(w => w.SaveChanges(), Times.Once);
        }
示例#3
0
        public void MockData()
        {
            var personDbSetMock =
                new Mock <DbSet <Customer> >();

            var webContextMock =
                new Mock <ContextoWebDb>();

            webContextMock.Setup(m => m.Customer).
            Returns(personDbSetMock.Object);

            webContextMock.Setup(m => m.Set <Customer>()).
            Returns(personDbSetMock.Object);

            var repositorio =
                new BaseRepositorio <Customer>(webContextMock.Object);
            var newPerson = TestPersonOk();

            repositorio.Agregar(newPerson);
            personDbSetMock.Verify(p => p.Add(It.IsAny <Customer>()),
                                   Times.Once);
            webContextMock.Verify(w => w.SaveChanges(),
                                  Times.Once);
        }