コード例 #1
0
ファイル: CommonController.cs プロジェクト: 0dylan0/Tiger
 public CommonController(IWorkContext webWorkContext,
                         PurchaseDataService purchaseDataService,
                         LocalizationService localizationService,
                         GoodsDataService goodsDataService,
                         SupplierDataService supplierDataService,
                         WarehouseService warehouseService,
                         InventoryDataService inventoryDataService,
                         GoodsSpecificationService goodsSpecificationService,
                         ClientTypeService clientTypeService,
                         SalesShipmentsDataService salesShipmentsDataService,
                         GoodsTypeService goodsTypeService,
                         SupplierTypeService supplierTypeService)
 {
     _webWorkContext            = webWorkContext;
     _purchaseDataService       = purchaseDataService;
     _localizationService       = localizationService;
     _goodsDataService          = goodsDataService;
     _supplierDataService       = supplierDataService;
     _warehouseService          = warehouseService;
     _inventoryDataService      = inventoryDataService;
     _goodsSpecificationService = goodsSpecificationService;
     _clientTypeService         = clientTypeService;
     _salesShipmentsDataService = salesShipmentsDataService;
     _goodsTypeService          = goodsTypeService;
     _supplierTypeService       = supplierTypeService;
 }
コード例 #2
0
        public void GetSupplierTypesPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_SupplierType> list = new List <R_SupplierType>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleSupplierType(i));
            }

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.GetSupplierTypes(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            var             resultList = supplierTypeService.GetSupplierTypes(searchTerm, pageIndex, pageSize);
            SupplierTypeDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.SupplierTypeId);
            Assert.AreEqual(10, resultList.Count);
        }
コード例 #3
0
        public void GetSupplierTypes_Success_Test()
        {
            // Arrange
            R_SupplierType supplierType = SampleSupplierType(1);

            IList <R_SupplierType> list = new List <R_SupplierType>();

            list.Add(supplierType);

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.GetSupplierTypes()).Returns(list);

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            var             resultList = supplierTypeService.GetSupplierTypes();
            SupplierTypeDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.SupplierTypeId);
        }
コード例 #4
0
 public SupplierTypeController(IWorkContext webWorkContext,
                               SupplierTypeService supplierTypeService,
                               LocalizationService localizationService)
 {
     _webWorkContext      = webWorkContext;
     _supplierTypeService = supplierTypeService;
     _localizationService = localizationService;
 }
コード例 #5
0
        public void GetSupplierTypeListAdvancedSearch_Success_Test()
        {
            // Arrange
            string name        = null;
            string description = null;
            bool?  active      = null;

            //int pageIndex = 0;
            int pageSize = 10;

            // list
            IList <R_SupplierType> list = new List <R_SupplierType>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleSupplierType(i));
            }

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.GetSupplierTypeListAdvancedSearch(
                           Moq.It.IsAny <string>()   // name
                           , Moq.It.IsAny <string>() // description
                           , Moq.It.IsAny <bool?>()  // active
                           )).Returns(list);

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            var resultList = supplierTypeService.GetSupplierTypeListAdvancedSearch(
                name
                , description
                , active
                );

            SupplierTypeDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.SupplierTypeId);
        }
コード例 #6
0
        public void DeleteSupplierTypeById_Success_Test()
        {
            // Arrange
            int id = 1;

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.DeleteSupplierType(Moq.It.IsAny <int>())).Verifiable();

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            supplierTypeService.DeleteSupplierType(id);

            // Assert
            Assert.IsTrue(true);
        }
コード例 #7
0
        public void UpdateSupplierType_Success_Test()
        {
            // Arrange
            SupplierTypeDTO dto = SampleSupplierTypeDTO(1);

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.UpdateSupplierType(Moq.It.IsAny <R_SupplierType>())).Verifiable();

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            supplierTypeService.UpdateSupplierType(dto);

            // Assert
            Assert.IsNotNull(dto);
        }
コード例 #8
0
        public void AddSupplierType_Success_Test()
        {
            // Arrange
            SupplierTypeDTO dto = SampleSupplierTypeDTO(1);

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.AddSupplierType(Moq.It.IsAny <R_SupplierType>())).Returns(1);

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            int id = supplierTypeService.AddSupplierType(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.SupplierTypeId);
        }
コード例 #9
0
        public void GetSupplierType_Success_Test()
        {
            // Arrange
            int            id           = 1;
            R_SupplierType supplierType = SampleSupplierType(id);

            // create mock for repository
            var mock = new Mock <ISupplierTypeRepository>();

            mock.Setup(s => s.GetSupplierType(Moq.It.IsAny <int>())).Returns(supplierType);

            // service
            SupplierTypeService supplierTypeService = new SupplierTypeService();

            SupplierTypeService.Repository = mock.Object;

            // Act
            SupplierTypeDTO result = supplierTypeService.GetSupplierType(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.SupplierTypeId);
        }
コード例 #10
0
 /// <summary>
 /// 下拉列表框
 /// </summary>
 /// <returns></returns>
 public static IQueryable GetSupplierType()
 {
     return(SupplierTypeService.GetSupplierType());
 }