Esempio n. 1
0
        public void SetUp()
        {
            var customer = new Customer
            {
                Id = CustomerId
            };

            var employee = new Employee
            {
                Id = EmployeeId
            };

            var product = new Product
            {
                Id    = ProductId,
                Price = UnitPrice
            };

            _model = new CreateSaleModel()
            {
                CustomerId = CustomerId,
                EmployeeId = EmployeeId,
                ProductId  = ProductId,
                Quantity   = Quantity
            };

            _sale = new Sale();

            _mocker = new AutoMoqer();

            _mocker.GetMock <IDateService>()
            .Setup(p => p.GetDate())
            .Returns(Date);

            _mocker.GetMock <ISaleRepositoryFacade>()
            .Setup(p => p.GetCustomer(CustomerId))
            .Returns(customer);

            _mocker.GetMock <ISaleRepositoryFacade>()
            .Setup(p => p.GetEmployee(EmployeeId))
            .Returns(employee);

            _mocker.GetMock <ISaleRepositoryFacade>()
            .Setup(p => p.GetProduct(ProductId))
            .Returns(product);

            _mocker.GetMock <ISaleFactory>()
            .Setup(p => p.Create(
                       Date,
                       customer,
                       employee,
                       product,
                       Quantity))
            .Returns(_sale);

            _command = _mocker.Create <CreateSaleCommand>();
        }
Esempio n. 2
0
        public void SetUp()
        {
            var customer = new Customer
            {
                Id = CustomerId
            };

            var employee = new Employee
            {
                Id = EmployeeId
            };

            var product = new Product
            {
                Id    = ProductId,
                Price = UnitPrice
            };

            _model = new CreateSaleModel
            {
                CustomerId = CustomerId,
                EmployeeId = EmployeeId,
                ProductId  = ProductId,
                Quantity   = Quantity
            };

            _sale = new Sale();

            _mocker = new AutoMoqer();

            _mocker.GetMock <IDateService>()
            .Setup(p => p.GetDate())
            .Returns(Date);

            SetUpDbSet(p => p.Customers, customer);
            SetUpDbSet(p => p.Employees, employee);
            SetUpDbSet(p => p.Products, product);
            SetUpDbSet(p => p.Sales);

            _mocker.GetMock <ISaleFactory>()
            .Setup(
                p => p.Create(
                    Date,
                    customer,
                    employee,
                    product,
                    Quantity))
            .Returns(_sale);

            _command = _mocker.Create <CreateSaleCommand>();
        }