Exemple #1
0
        internal Trip PopulateNewItem()
        {
            Trip trip = new Trip();

            trip.StartDate  = DateTime.Today;
            trip.TripNumber = "12345678";

            Warehouse warehouse = WarehouseTests.PopulateNewItem();

            trip.WarehouseId = WarehouseController.SaveWarehouse(warehouse);

            trip.LeaveTime         = DateTime.Now.ToShortTimeString();
            trip.FinishTime        = DateTime.Now.AddMinutes(10).ToShortTimeString();
            trip.PeakWeight        = 1;
            trip.PeakVolume        = 2;
            trip.MaximumLoadWeight = 1;
            trip.MaximumLoadVolume = 2;
            trip.VehicleCost       = 99;

            trip.RegionId            = warehouse.RegionId;
            trip.VehicleRegistration = "NN56 TDC";
            trip.AssignedDriver      = "TDC AssignedDriver";
            trip.TotalDistance       = 100;
            //trip.LoadingTime = 20;
            //trip.TravellingTime = 30;
            //trip.WaitingTime = 40;
            trip.UpdatedBy = "TDC Team";

            return(trip);
        }
Exemple #2
0
        public void CalculateDeliveryDate()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                TDCShipment tdcShipment = new TDCShipment();

                //set-up two warehouses
                Warehouse stockWarehouse = WarehouseTests.PopulateNewItem();
                WarehouseTests.SaveItem(stockWarehouse);
                tdcShipment.StockWarehouseCode = stockWarehouse.Code;

                Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem();
                WarehouseTests.SaveItem(deliveryWarehouse);
                tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code;

                //set-up trunker days
                TrunkerDay trunkerDay = new TrunkerDay();
                trunkerDay.Days = 3;
                trunkerDay.SourceWarehouseId      = tdcShipment.StockWarehouse.Id;
                trunkerDay.DestinationWarehouseId = tdcShipment.DeliveryWarehouse.Id;
                trunkerDay.UpdatedBy = "me";
                trunkerDay.Id        = TrunkerDaysController.SaveTrunkerDay(trunkerDay);


                tdcShipment.RequiredShipmentDate  = new DateTime(2006, 07, 24);
                tdcShipment.OpCoCode              = "HSP";
                tdcShipment.StockWarehouseCode    = tdcShipment.StockWarehouse.Code;
                tdcShipment.DeliveryWarehouseCode = tdcShipment.DeliveryWarehouse.Code;
                tdcShipment.CalculateDeliveryDate();

                Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 27));
            }
        }
Exemple #3
0
        public void CalculateDeliveryDateSameWarehouseSameDay()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                //set-up two warehouses

                TDCShipment tdcShipment = new TDCShipment();

                Warehouse stockWarehouse = WarehouseTests.PopulateNewItem();
                WarehouseTests.SaveItem(stockWarehouse);
                tdcShipment.StockWarehouseCode    = stockWarehouse.Code;
                tdcShipment.DeliveryWarehouseCode = stockWarehouse.Code;
                tdcShipment.RequiredShipmentDate  = new DateTime(2006, 07, 24);
                tdcShipment.OpCoCode = "HSP";
                Route route = RouteTests.PopulateNewItem();
                route.IsNextDay = false;
                route.IsSameDay = true;
                RouteTests.SaveItem(route);
                tdcShipment.RouteCode = route.Code;

                tdcShipment.CalculateDeliveryDate();


                Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 24));
            }
        }
Exemple #4
0
        public void CalculateDeliveryDateWithWeekend()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                //set-up two warehouses
                TDCShipment tdcShipment = new TDCShipment();

                Warehouse stockWarehouse = WarehouseTests.PopulateNewItem();
                WarehouseTests.SaveItem(stockWarehouse);
                tdcShipment.StockWarehouseCode = stockWarehouse.Code;

                Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem();
                WarehouseTests.SaveItem(deliveryWarehouse);
                tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code;



                //set-up non working days
                //saturday
                NonWorkingDay nonWorkingDay = new NonWorkingDay();
                nonWorkingDay.NonWorkingDate = new DateTime(2006, 07, 29);
                nonWorkingDay.Description    = "sat";
                nonWorkingDay.UpdatedBy      = "me";
                nonWorkingDay.WarehouseId    = tdcShipment.DeliveryWarehouse.Id;
                NonWorkingDayController.SaveNonWorkingDay(nonWorkingDay);

                //sunday
                nonWorkingDay = new NonWorkingDay();
                nonWorkingDay.NonWorkingDate = new DateTime(2006, 07, 30);
                nonWorkingDay.Description    = "sun";
                nonWorkingDay.UpdatedBy      = "me";
                nonWorkingDay.WarehouseId    = tdcShipment.DeliveryWarehouse.Id;
                NonWorkingDayController.SaveNonWorkingDay(nonWorkingDay);

                //set-up trunker days
                TrunkerDay trunkerDay = new TrunkerDay();
                trunkerDay.Days = 3;
                trunkerDay.SourceWarehouseId      = tdcShipment.StockWarehouse.Id;
                trunkerDay.DestinationWarehouseId = tdcShipment.DeliveryWarehouse.Id;
                trunkerDay.UpdatedBy = "me";
                trunkerDay.Id        = TrunkerDaysController.SaveTrunkerDay(trunkerDay);


                tdcShipment.RequiredShipmentDate  = new DateTime(2006, 07, 26);
                tdcShipment.OpCoCode              = "HSP";
                tdcShipment.StockWarehouseCode    = tdcShipment.StockWarehouse.Code;
                tdcShipment.DeliveryWarehouseCode = tdcShipment.DeliveryWarehouse.Code;
                tdcShipment.CalculateDeliveryDate();

                Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 31));
            }
        }
Exemple #5
0
        /// <summary>
        /// Populates the new item.
        /// </summary>
        /// <returns></returns>
        internal NonWorkingDay PopulateNewItem()
        {
            NonWorkingDay nonWorkingDay = new NonWorkingDay();

            nonWorkingDay.NonWorkingDate = DateTime.Today;
            nonWorkingDay.Description    = DateTime.Today.DayOfWeek.ToString();
            nonWorkingDay.UpdatedDate    = DateTime.Today;
            nonWorkingDay.UpdatedBy      = "TDC Team";

            Warehouse warehouse = WarehouseTests.PopulateNewItem();

            nonWorkingDay.WarehouseCode = warehouse.Code;
            nonWorkingDay.WarehouseId   = WarehouseController.SaveWarehouse(warehouse);

            return(nonWorkingDay);
        }
        internal TrunkerDay PopulateNewItem()
        {
            TrunkerDay trunkerDay = new TrunkerDay();

            trunkerDay.Days      = 3;
            trunkerDay.UpdatedBy = "IanKilsby";

            // Set up 2 Warehouses
            // First warehouse is IPS created by using the warehouse pouulate method


            trunkerDay.SourceWarehouse      = WarehouseTests.PopulateNewItem();
            trunkerDay.SourceWarehouse.Code = "IPS";
            trunkerDay.SourceWarehouseId    = WarehouseTests.SaveItem(trunkerDay.SourceWarehouse);


            // Second warehouse cannot use the populate method due to duplicate foreign keys e.g. printer etc

            trunkerDay.DestinationWarehouse                         = new Warehouse();
            trunkerDay.DestinationWarehouse.Description             = "London Warehouse";
            trunkerDay.DestinationWarehouse.UpdatedBy               = "IanKilsby";
            trunkerDay.DestinationWarehouse.Contact                 = new Contact();
            trunkerDay.DestinationWarehouse.Contact.Name            = "ContactName";
            trunkerDay.DestinationWarehouse.Contact.TelephoneNumber = "TelephoneNumber";
            trunkerDay.DestinationWarehouse.Contact.Email           = "SalesEmail";
            trunkerDay.DestinationWarehouse.HasCommander            = true;
            trunkerDay.DestinationWarehouse.HasOptrak               = true;
            trunkerDay.DestinationWarehouse.IsTDC                   = true;

            // trunkerDay.DestinationWarehouse.PrinterName = trunkerDay.SourceWarehouse.PrinterName;
            //trunkerDay.DestinationWarehouse.PrinterId = trunkerDay.SourceWarehouse.Printer.Id;

            trunkerDay.DestinationWarehouse.OptrakRegion     = trunkerDay.SourceWarehouse.OptrakRegion;
            trunkerDay.DestinationWarehouse.OptrakRegion.Id  = trunkerDay.SourceWarehouse.RegionId;
            trunkerDay.DestinationWarehouse.RegionId         = trunkerDay.SourceWarehouse.RegionId;
            trunkerDay.DestinationWarehouse.Address          = new Address();
            trunkerDay.DestinationWarehouse.Address.Line1    = "line1";
            trunkerDay.DestinationWarehouse.Address.Line2    = "line2";
            trunkerDay.DestinationWarehouse.Address.Line3    = "line3";
            trunkerDay.DestinationWarehouse.Address.Line4    = "line4";
            trunkerDay.DestinationWarehouse.Address.PostCode = "PostCode";
            trunkerDay.DestinationWarehouse.Code             = "LON";
            trunkerDay.DestinationWarehouseId = WarehouseTests.SaveItem(trunkerDay.DestinationWarehouse);

            return(trunkerDay);
        }
        public void GetItems_CheckSort()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                //add a trunker day with a high number of days
                TrunkerDay trunkerDay = PopulateNewItem();
                trunkerDay.Days = 10;
                int id = TrunkerDaysController.SaveTrunkerDay(trunkerDay);
                if (id > -1)
                {
                    //add a trunker day with a lower number of days
                    trunkerDay    = trunkerDay.DeepClone <TrunkerDay>();
                    trunkerDay.Id = -1;
                    trunkerDay.DestinationWarehouse    = WarehouseTests.PopulateNewItem();
                    trunkerDay.DestinationWarehouse.Id = WarehouseController.SaveWarehouse(trunkerDay.DestinationWarehouse);
                    trunkerDay.DestinationWarehouseId  = trunkerDay.DestinationWarehouse.Id;
                    trunkerDay.Days = 5;
                    int id2 = TrunkerDaysController.SaveTrunkerDay(trunkerDay);

                    if (id2 > -1)
                    {
                        //retrieve all trunker days and the one we saved should return at least
                        List <TrunkerDay> trunkerDays = TrunkerDaysController.GetTrunkerDays(false, "Days");

                        //so the count should be >0
                        Assert.IsTrue(trunkerDays.Count > 0);
                        //find the two we added
                        trunkerDays = trunkerDays.FindAll(delegate(TrunkerDay currentItem)
                        {
                            return(currentItem.Id == id || currentItem.Id == id2);
                        });
                        Assert.IsTrue(trunkerDays.Count == 2);

                        Assert.IsTrue(trunkerDays[0].Days < trunkerDays[1].Days);
                    }
                }
            }
        }
Exemple #8
0
        static internal TDCShipment PopulateItem()
        {
            TDCShipment  tdcShipment  = new TDCShipment();
            OpCoShipment opCoShipment = OpcoShipmentTests.PopulateNewItem();

            try
            {
                tdcShipment.OpCoShipmentId = OpCoShipmentController.SaveShipment(opCoShipment);
            }
            catch (InValidBusinessObjectException e)
            {
                Console.Write(e.ValidatableObject.ValidationMessages);
            }

            tdcShipment.OpCoCode           = opCoShipment.OpCoCode;
            tdcShipment.OpCoSequenceNumber = 1;

            tdcShipment.OpCoContact.Email        = "Email";
            tdcShipment.OpCoContact.Name         = "Name";
            tdcShipment.DespatchNumber           = "Number";
            tdcShipment.RequiredShipmentDate     = DateTime.Now;
            tdcShipment.CustomerNumber           = "CustNo";
            tdcShipment.CustomerName             = "CustomerName";
            tdcShipment.CustomerReference        = "ref";
            tdcShipment.CustomerAddress.Line1    = "Line1";
            tdcShipment.CustomerAddress.PostCode = "NN8 1NB";
            tdcShipment.ShipmentNumber           = "ShipNo";
            tdcShipment.ShipmentName             = "ShipmentName";
            tdcShipment.ShipmentAddress.Line1    = "Line1";
            tdcShipment.ShipmentAddress.PostCode = "NN8 1NB";
            tdcShipment.SalesBranchCode          = "BranchCode";
            tdcShipment.AfterTime           = "11:11";
            tdcShipment.BeforeTime          = "10:10";
            tdcShipment.TailLiftRequired    = false;
            tdcShipment.CheckInTime         = 1;
            tdcShipment.DivisionCode        = "Div";
            tdcShipment.GeneratedDateTime   = DateTime.Now;
            tdcShipment.Status              = Shipment.StatusEnum.Mapped;
            tdcShipment.IsRecurring         = false;
            tdcShipment.IsValidAddress      = false;
            tdcShipment.PAFAddress.Line1    = "Line1";
            tdcShipment.PAFAddress.PostCode = "PostCode";
            tdcShipment.UpdatedBy           = "UpdatedBy";
            tdcShipment.Instructions        = "Instructions";
            tdcShipment.VehicleMaxWeight    = (decimal)1.1;
            OpCoDivision division = OpcoDivisionTests.PopulateNewItem();

            OpcoDivisionTests.SaveItem(division);
            tdcShipment.DivisionCode = division.Code;

            Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem();

            WarehouseTests.SaveItem(deliveryWarehouse);
            tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code;

            Warehouse stockWarehouse = WarehouseTests.PopulateNewItem();

            WarehouseTests.SaveItem(stockWarehouse);
            tdcShipment.StockWarehouseCode = stockWarehouse.Code;

            Route route = RouteTests.PopulateNewItem();

            RouteTests.SaveItem(route);
            tdcShipment.RouteCode = route.Code;

            TransactionType transactionType = TransactionTypeTests.PopulateNewItem();

            TransactionTypeTests.SaveItem(transactionType);
            tdcShipment.TransactionTypeCode = transactionType.Code;

            TransactionSubType transactionSubType = TransactionSubTypeTests.PopulateNewItem();

            TransactionSubTypeTests.SaveItem(transactionSubType);
            tdcShipment.TransactionSubTypeCode = transactionSubType.Code;

            return(tdcShipment);
        }