public async Task MoveSalesPersonWithoutGroupToExistingGroupMoq()
        {
            var srMock  = new Mock <ISalesPersonRepository>();
            var sgrMock = new Mock <ITrackingRepository <SalesGroup> >();

            var salesperson = new Salesperson()
            {
                Id = 1
            };

            sgrMock.Setup(x => x.GetByID(1)).Returns(Task.FromResult(new SalesGroup()
            {
                Id = 1, State = "TEST"
            }));

            srMock.Setup(x => x.GetByID(1)).Returns(Task.FromResult(salesperson));

            srMock.Setup(x => x.Save(It.IsAny <Salesperson>())).Callback <Salesperson>(p => salesperson = p);

            var service = new SalesPersonService(srMock.Object, sgrMock.Object);

            await service.MoveSalesPersonToGroup(1, 1);

            var person = await srMock.Object.GetByID(1);

            Assert.IsTrue(person.SalesGroup.State == "TEST");
        }
Exemplo n.º 2
0
        public async void StoresBySalesPersonID_Exists()
        {
            var mock    = new ServiceMockFacade <ISalesPersonRepository>();
            var records = new List <Store>();

            records.Add(new Store());
            mock.RepositoryMock.Setup(x => x.StoresBySalesPersonID(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new SalesPersonService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesOrderHeaderMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesOrderHeaderMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesTerritoryHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesTerritoryHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                                 mock.DALMapperMockFactory.DALStoreMapperMock);

            List <ApiStoreResponseModel> response = await service.StoresBySalesPersonID(default(int));

            response.Should().NotBeEmpty();
            mock.RepositoryMock.Verify(x => x.StoresBySalesPersonID(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
Exemplo n.º 3
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <ISalesPersonRepository>();
            var record = new SalesPerson();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new SalesPersonService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesOrderHeaderMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesOrderHeaderMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesTerritoryHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesTerritoryHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                                 mock.DALMapperMockFactory.DALStoreMapperMock);

            ApiSalesPersonResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemplo n.º 4
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <ISalesPersonRepository>();
            var records = new List <SalesPerson>();

            records.Add(new SalesPerson());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new SalesPersonService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesOrderHeaderMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesOrderHeaderMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesTerritoryHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesTerritoryHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                                 mock.DALMapperMockFactory.DALStoreMapperMock);

            List <ApiSalesPersonResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Exemplo n.º 5
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <ISalesPersonRepository>();
            var model = new ApiSalesPersonRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new SalesPersonService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesOrderHeaderMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesOrderHeaderMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesTerritoryHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesTerritoryHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                                 mock.DALMapperMockFactory.DALStoreMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
Exemplo n.º 6
0
        public async void Update()
        {
            var mock  = new ServiceMockFacade <ISalesPersonRepository>();
            var model = new ApiSalesPersonRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <SalesPerson>())).Returns(Task.FromResult(new SalesPerson()));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new SalesPerson()));
            var service = new SalesPersonService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesOrderHeaderMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesOrderHeaderMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLSalesTerritoryHistoryMapperMock,
                                                 mock.DALMapperMockFactory.DALSalesTerritoryHistoryMapperMock,
                                                 mock.BOLMapperMockFactory.BOLStoreMapperMock,
                                                 mock.DALMapperMockFactory.DALStoreMapperMock);

            UpdateResponse <ApiSalesPersonResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.SalesPersonModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiSalesPersonRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Update(It.IsAny <SalesPerson>()));
        }
        // Lấy ra tên nhân viên
        private void txEmp_TextChanged(object sender, EventArgs e)
        {
            SalesPerson sl = SalesPersonService.FindOne(txEmp.Text);

            if (sl != null)
            {
                txEmpName.Text = sl.SlsPerName;
            }
        }
Exemplo n.º 8
0
        // Load tên người nộp vào tree view
        void LoadSlsPer()
        {
            int i = 0;

            foreach (SalesPerson slsper in SalesPersonService.GetAll())
            {
                treeSlsPer.Nodes[0].Nodes.Add(slsper.SlsPerName);                        // Add tên người nộp
                treeSlsPer.Nodes[0].Nodes[i++].Tag = slsper.SlsPerID;                    // Tag node với mã người nộp để tìm kiếm theo Tag
            }
            treeSlsPer.ExpandAll();
        }
        private void frmEmployee_Load(object sender, EventArgs e)
        {
            this.salesPersonBindingSource.DataSource = SalesPersonService.GetAll();                             // Load dữ liệu lên gridview

            DataTable dt = new DataTable();

            dt.Columns.Add("val", typeof(string));
            dt.Columns.Add("dis", typeof(string));
            dt.Rows.Add(new object[] { "0", "Hết hiệu lực" });
            dt.Rows.Add(new object[] { "1", "Còn hiệu lực" });
            comboBox1.DataSource = dt;
        }
Exemplo n.º 10
0
        public async Task MoveSalesPersonWithoutGroupToExistingGroup()
        {
            var salesRepo      = new SalesPersonRepositoryMock();
            var salesGroupRepo = new SalesGroupRepositoryMock();

            salesGroupRepo.Add(new SalesGroup()
            {
                State = "TEST", Type = 1, Id = 1
            });
            salesRepo.Add(new Salesperson()
            {
                Id = 1
            });

            var service = new SalesPersonService(salesRepo, salesGroupRepo);

            await service.MoveSalesPersonToGroup(1, 1);

            var person = await salesRepo.GetByID(1);

            Assert.IsTrue(person.SalesGroup.State == "TEST");
        }
Exemplo n.º 11
0
        static async Task Main(string[] args)
        {
            var queue = new MessageQueue(@".\private$\OrdersQueue")
            {
                Formatter = new XmlMessageFormatter(new String[] { "System.String" })
            };

            UnitOfWork unitOfWork = new UnitOfWork();

            var salesPersonService = new SalesPersonService(unitOfWork);

            foreach (Message message in queue.GetAllMessages())
            {
                var id = int.Parse(message.Label);
                await salesPersonService.ChangeOrderStatus(id);

                Console.WriteLine(message.Label);
                Console.WriteLine(message.Body);
                Console.WriteLine("------------------------");
            }

            queue.Purge();
            Console.ReadKey();
        }
 private void btSave_Click(object sender, EventArgs e)
 {
     SalesPersonService.Save();
 }