Exemplo n.º 1
0
        private void SetUpDbSet <T>(Expression <Func <IDatabaseService, DbSet <T> > > property)
            where T : class
        {
            var createSaleMock = CreateDbSetMock.SetUpDbSet(new List <T> {
            }.AsQueryable());

            _mocker.GetMock <IDatabaseService>()
            .Setup(property)
            .Returns(createSaleMock.Object);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            _mocker = new AutoMoqer();

            _employee = new Employee()
            {
                Id   = Id,
                Name = Name
            };

            var employeeMock = CreateDbSetMock.SetUpDbSet(new List <Employee> {
                _employee
            }.AsQueryable());

            _mocker.GetMock <IDatabaseService>()
            .Setup(p => p.Employees)
            .Returns(employeeMock.Object);

            _query = _mocker.Create <GetEmployeesListQuery>();
        }
        public void SetUp()
        {
            _mocker = new AutoMoqer();

            _customer = new Customer()
            {
                Id   = Id,
                Name = Name
            };

            var customersMock = CreateDbSetMock.SetUpDbSet(new List <Customer> {
                _customer
            }.AsQueryable());

            _mocker.GetMock <IDatabaseService>()
            .Setup(p => p.Customers)
            .Returns(customersMock.Object);

            _query = _mocker.Create <GetCustomersListQuery>();
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            var customer = new Customer
            {
                Name = CustomerName
            };

            var employee = new Employee
            {
                Name = EmployeeName
            };

            var product = new Product
            {
                Name = ProductName
            };

            _sale = new Sale()
            {
                Id        = SaleId,
                Date      = Date,
                Customer  = customer,
                Employee  = employee,
                Product   = product,
                UnitPrice = UnitPrice,
                Quantity  = Quantity
            };

            _mocker = new AutoMoqer();

            var saleMock = CreateDbSetMock.SetUpDbSet(new List <Sale> {
                _sale
            }.AsQueryable());

            _mocker.GetMock <IDatabaseService>()
            .Setup(p => p.Sales)
            .Returns(saleMock.Object);

            _query = _mocker.Create <GetSalesListQuery>();
        }
Exemplo n.º 5
0
        public void TestExecuteShouldReturnSaleDetail()
        {
            var saleMock = CreateDbSetMock.SetUpDbSet(new List <Sale> {
                _sale
            }.AsQueryable());

            _mocker.GetMock <IDatabaseService>()
            .Setup(p => p.Sales)
            .Returns(saleMock.Object);

            var result = _query.Execute(SaleId);

            Assert.That(result.Id,
                        Is.EqualTo(SaleId));

            Assert.That(result.Date,
                        Is.EqualTo(Date));

            Assert.That(result.CustomerName,
                        Is.EqualTo(CustomerName));

            Assert.That(result.EmployeeName,
                        Is.EqualTo(EmployeeName));

            Assert.That(result.ProductName,
                        Is.EqualTo(ProductName));

            Assert.That(result.UnitPrice,
                        Is.EqualTo(UnitPrice));

            Assert.That(result.Quantity,
                        Is.EqualTo(Quantity));

            Assert.That(result.TotalPrice,
                        Is.EqualTo(TotalPrice));
        }