Esempio n. 1
0
        public void ImportWarehouse_IsOk()
        {
            Mock <IWarehouseRepository> mock = new Mock <IWarehouseRepository>();

            WarehouseNextHops nexthop1 = new WarehouseNextHops()
            {
                Hop = new Warehouse(), TraveltimeMins = 1
            };
            WarehouseNextHops nexthop2 = new WarehouseNextHops()
            {
                Hop = new Warehouse(), TraveltimeMins = 2
            };
            IEnumerable <WarehouseNextHops> nextHops = new List <WarehouseNextHops>()
            {
                nexthop1, nexthop2
            };
            Warehouse wh = new Warehouse()
            {
                Code = "123456789", Description = "a valid one", ProcessingDelayMins = 1, NextHops = nextHops
            };

            IWarehouseManagementLogic warehouseManagementLogic = new WarehouseManagementLogic(mapper, mock.Object, NullLogger <WarehouseManagementLogic> .Instance);

            warehouseManagementLogic.ImportWarehouse(wh);

            /// if it doesn't throw we good
        }
Esempio n. 2
0
        public void ImportWarehouse_InvalidWarehouse(string code, string description)
        {
            Mock <IWarehouseRepository> mock = new Mock <IWarehouseRepository>();

            WarehouseNextHops nexthop1 = new WarehouseNextHops()
            {
                Hop = new Warehouse(), TraveltimeMins = 1
            };
            WarehouseNextHops nexthop2 = new WarehouseNextHops()
            {
                Hop = new Warehouse(), TraveltimeMins = 2
            };
            IEnumerable <WarehouseNextHops> nextHops = new List <WarehouseNextHops>()
            {
                nexthop1, nexthop2
            };
            Warehouse wh = new Warehouse()
            {
                Code = code, Description = description, ProcessingDelayMins = 1, NextHops = nextHops
            };

            IWarehouseManagementLogic warehouseManagementLogic = new WarehouseManagementLogic(mapper, mock.Object, NullLogger <WarehouseManagementLogic> .Instance);

            Assert.Throws <InvalidWarehouseException>(() => warehouseManagementLogic.ImportWarehouse(wh));
        }
Esempio n. 3
0
        public void ExportWarehouse_ReadException()
        {
            Mock <IWarehouseRepository> mock = new Mock <IWarehouseRepository>();

            mock.Setup(foo => foo.Read()).Throws(new WarehouseNotFoundExpection());

            IWarehouseManagementLogic warehouseManagementLogic = new WarehouseManagementLogic(mapper, mock.Object, NullLogger <WarehouseManagementLogic> .Instance);

            Assert.Throws <BusinessLayerException>(() => warehouseManagementLogic.ExportWarehouse());
        }
        public WarehouseManagementLogicTest()
        {
            var config = new MapperConfiguration(cfg => cfg.AddProfile(new SKSLayerMapper()));

            _mapper     = new AutoMapper.Mapper(config);
            _mock       = new Mock <IHopRepository>();
            _controller = new WarehouseManagementLogic(_mock.Object, _mapper, new LoggerFactory().CreateLogger <WarehouseManagementLogic>());


            wh = new BL.Warehouse()
            {
                Description = "BNDA04"
            };
        }
Esempio n. 5
0
        public void ExportWarehouse_IsOk()
        {
            string code = "123456789";
            Mock <IWarehouseRepository> mock = new Mock <IWarehouseRepository>();

            DA.Warehouse wh = new DA.Warehouse()
            {
                Code = code
            };
            mock.Setup(foo => foo.Read()).Returns(wh);
            IWarehouseManagementLogic warehouseManagementLogic = new WarehouseManagementLogic(mapper, mock.Object, NullLogger <WarehouseManagementLogic> .Instance);

            Warehouse w = warehouseManagementLogic.ExportWarehouse();

            Assert.NotNull(w);
            Assert.Equal(code, w.Code);
        }