public void ReportDeliveryFinal_ShouldReturnTrue_WhenSucceeds()
        {
            string trackingId = "PYJRB4HZ6";

            DAL.Receipient customer = new DAL.Receipient()
            {
                Name       = "Johannes",
                Street     = "Street",
                PostalCode = "A-1230"
            };
            var hop = new DAL.HopArrival()
            {
                Code = "BNDA01"
            };

            DAL.Parcel DALp = new DAL.Parcel()
            {
                TrackingId = trackingId,
                Receipient = customer,
                Sender     = customer
            };

            DALp.FutureHops.Add(hop);
            _mock.Setup(x => x.GetByTrackingID(trackingId)).Returns(DALp);
            _mock.Setup(x => x.Update(It.IsAny <DAL.Parcel>()));
            List <DAL.Webhook> deleteList = new List <DAL.Webhook>();

            _mockHook.Setup(x => x.GetWebhooksByTrackingID(trackingId)).Returns(deleteList);
            // Act
            var result = _controller.ReportDeliveryFinal(trackingId);

            // Assert
            Assert.IsTrue(result);
        }
        public void ReportDeliveryFinal_ShouldReturnFalse_WhenNotValid()
        {
            string trackingId = "PYJRB4HZ6";

            DAL.Receipient customer = new DAL.Receipient()
            {
                Name       = "Johannes",
                Street     = "Street",
                PostalCode = "FALSCH"
            };
            var hop = new DAL.HopArrival()
            {
                Code = "BNDA01"
            };

            DAL.Parcel DALp = new DAL.Parcel()
            {
                TrackingId = trackingId,
                Receipient = customer,
                Sender     = customer
            };

            DALp.FutureHops.Add(hop);
            _mock.Setup(x => x.GetByTrackingID(trackingId)).Returns(DALp);
            _mock.Setup(x => x.Update(It.IsAny <DAL.Parcel>()));
            // Act
            var result = _controller.ReportDeliveryFinal(trackingId);

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #3
0
        public void TrackPackage_isNull_WhenNOTFound()
        {
            string trackingId = "ABCDEF123";

            DAL.Parcel p = null;

            _mock.Setup(x => x.GetByTrackingID(trackingId))
            .Returns(p);

            Assert.IsNull(p);
        }
        public void ReportDeliveryFinal_ShouldReturnFalse_WhenNotSucceeds()
        {
            string trackingId = "FALSCH";

            DAL.Parcel p = null;
            _mock.Setup(x => x.GetByTrackingID(trackingId)).Returns(p);
            // Act
            var result = _controller.ReportDeliveryFinal(trackingId);

            // Assert
            Assert.IsFalse(result);
        }
        public void StaffReportHop_ShouldReturnFalse_WhenNOTSucceeds()
        {
            string trackingId = "FALSCH";
            string code       = "BNDA04";

            DAL.Parcel p = null;
            DAL.Hop    h = null;
            _mock.Setup(x => x.GetByTrackingID(trackingId)).Returns(p);
            _mockHOP.Setup(x => x.GetByCode(code)).Returns(h);
            // Act
            var result = _controller.StaffReportHop(trackingId, code);

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #6
0
        public void TrackPackage_ShouldReturnException_WhenNOTSucceeds()
        {
            string trackingId = "ABCDEF123";

            DAL.Parcel p = new DAL.Parcel()
            {
                TrackingId = "ABCDEF123"
            };

            _mock.Setup(x => x.GetByTrackingID(trackingId)).Throws(new Exception("HINIG"));

            BLException exc = Assert.Throws <BLException>(() => _controller.TrackPackage(trackingId));

            Assert.AreEqual("HINIG", exc.InnerException.Message);
        }
        public void TransferParcelPartner_ShouldsafeOldTrackingID_WhenSucceeds()
        {
            string newtrackingId = "ABCDE";
            string oldtrackingId = "XXXXX";

            DAL.Parcel p = new DAL.Parcel()
            {
                TrackingId = "ABCDE"
            };
            _mock.Setup(x => x.GetByTrackingID(newtrackingId)).Returns(p);
            _mock.Setup(x => x.Update(It.IsAny <DAL.Parcel>()));
            // Act

            _controller.TransferParcelPartner(newtrackingId, oldtrackingId);
            // Assert
            Assert.AreEqual(oldtrackingId, p.OldTrackingId);
        }
 public Parcel TrackPackage(string trackingId)
 {
     try
     {
         DAL.Parcel p = _sqlRepo.GetByTrackingID(trackingId);
         return(_mapper.Map <Parcel>(p));
     }
     catch (DAL.DALException exc)
     {
         _logger.LogError(exc.ToString());
         throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc);
     }
     catch (Exception exc)
     {
         _logger.LogError(exc.ToString());
         throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc);
     }
 }
Beispiel #9
0
        public void TrackPackage_ShouldReturnParcel_WhenValidTrackingID()
        {
            string trackingId = "ABCDEF123";

            DAL.Parcel p = new DAL.Parcel()
            {
                TrackingId = "ABCDEF123"
            };

            _mock.Setup(x => x.GetByTrackingID(trackingId))
            .Returns(p);

            // Act
            var result = _controller.TrackPackage(trackingId);

            // Assert
            Assert.AreEqual(trackingId, result.TrackingId);
        }
 public void TransferParcelPartner(string newtrackingId, string oldtrackingId)
 {
     try
     {
         DAL.Parcel p = _sqlRepo.GetByTrackingID(newtrackingId);
         p.OldTrackingId = oldtrackingId;
         _sqlRepo.Update(p);
     }
     catch (DAL.DALException exc)
     {
         _logger.LogError(exc.ToString());
         throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc);
     }
     catch (Exception exc)
     {
         _logger.LogError(exc.ToString());
         throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc);
     }
 }
Beispiel #11
0
        public void StaffReportHop_ShouldReturnTrue_WhenSucceeds_Truck()
        {
            string trackingId = "PYJRB4HZ6";
            string code       = "BNDA04";

            DAL.Receipient customer = new DAL.Receipient()
            {
                Name       = "Johannes",
                Street     = "Street",
                PostalCode = "A-1230"
            };
            var hop = new DAL.HopArrival()
            {
                Code = "BNDA04"
            };

            DAL.Parcel DALp = new DAL.Parcel()
            {
                TrackingId = trackingId,
                Receipient = customer,
                Sender     = customer
            };

            DAL.Warehouse wh = new DAL.Warehouse()
            {
                Code        = "ABC233",
                Description = "Truck",
                HopType     = "Truck"
            };

            DALp.FutureHops.Add(hop);
            DALp.FutureHops.Add(hop);
            _mock.Setup(x => x.GetByTrackingID(trackingId)).Returns(DALp);
            _mockHOP.Setup(x => x.GetByCode(code)).Returns(wh);
            _mock.Setup(x => x.Update(It.IsAny <DAL.Parcel>()));
            //moq
            // Act
            var result = _controller.StaffReportHop(trackingId, code);

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #12
0
        public SenderLogicTest()
        {
            var config = new MapperConfiguration(cfg => cfg.AddProfile(new SKSLayerMapper()));

            _mapper     = new AutoMapper.Mapper(config);
            _mockParcel = new Mock <IParcelRepository>();
            _mockHop    = new Mock <IHopRepository>();
            _agent      = new Mock <IGeocoderAgent>();
            _controller = new SenderLogic(_mockParcel.Object, _mockHop.Object, _mapper, _agent.Object, new LoggerFactory().CreateLogger <SenderLogic>());

            customer = new Receipient()
            {
                Name       = "Johannes",
                Street     = "Street",
                PostalCode = "A-1230"
            };
            DALcustomer = new DAL.Receipient()
            {
                Name       = "Johannes",
                Street     = "Street",
                PostalCode = "A-1230"
            };
            parcel = new Parcel()
            {
                Weight     = 1,
                State      = Parcel.StateEnum.InTransportEnum,
                Receipient = customer,
                Sender     = customer,
                TrackingId = "ABCDEF123"
            };
            DALparcel = new DAL.Parcel()
            {
                Weight     = 1,
                State      = DAL.Parcel.StateEnum.InTransportEnum,
                Receipient = DALcustomer,
                Sender     = DALcustomer,
                TrackingId = "ABCDEF123"
            };
            DALtruck = new DAL.Truck()
            {
                Code        = "AUTA05",
                NumberPlate = "lul"
            };
            roothop = new DAL.Warehouse()
            {
                Code        = "AUTA05",
                Description = "DEBUG",
                HopType     = "Warehouse",
                NextHops    = new List <DAL.WarehouseNextHops>()
                {
                    new DAL.WarehouseNextHops()
                    {
                        HopACode = "AUTA05",
                        HopBCode = "BNDA04",
                        HopB     = new DAL.Warehouse()
                        {
                            Code = "BNDA04"
                        }
                    }
                }
            };
        }