Exemple #1
0
 public void GetItems()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         if (MappingController.DeleteAllMappings())
         {
             if (MappingController.DeleteAllMappingSystems())
             {
                 if (MappingController.DeleteAllMappingPropertyAssociations())
                 {
                     if (MappingController.DeleteAllMappingClassAssociations())
                     {
                         Mapping mapping = PopulateMappingItem();
                         mapping.Id = MappingController.SaveMapping(mapping);
                         if (mapping.Id != -1)
                         {
                             List <Mapping> mappings = MappingController.GetMappings();
                             //so the count should be >0
                             Assert.IsTrue(mappings.Count > 0);
                             //check for our new id
                             Assert.IsTrue(mappings.Find(delegate(Mapping currentItem)
                             {
                                 return(currentItem.Id == mapping.Id);
                             }) != null);
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public void GetMappingLookup()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                if (MappingController.DeleteAllMappings())
                {
                    if (MappingController.DeleteAllMappingSystems())
                    {
                        if (MappingController.DeleteAllMappingPropertyAssociations())
                        {
                            if (MappingController.DeleteAllMappingClassAssociations())
                            {
                                Mapping mapping = PopulateMappingItem();
                                if (MappingController.SaveMapping(mapping) != -1)
                                {
                                    //we have set the lookup table to be route so we should add a route and then when we get the lookup list
                                    //back it should include the RouteCode we save in the routing table

                                    Route route = RouteTests.PopulateNewItem();
                                    if (RouteTests.SaveItem(route) != -1)
                                    {
                                        //get a list of route codes from the route table
                                        Dictionary <string, string> lookupList = MappingController.GetMappingLookup(mapping.MappingPropertyAssociationId);
                                        //so the count should be >0
                                        Assert.IsTrue(lookupList.Count > 0);
                                        //check for our new id
                                        Assert.IsTrue(lookupList.ContainsValue(route.Description));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void ConcurrencyTest()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                MappingController.DeleteAllMappings();
                MappingController.DeleteAllMappingSystems();
                MappingController.DeleteAllMappingPropertyAssociations();
                MappingController.DeleteAllMappingClassAssociations();

                try
                {
                    Mapping item = PopulateMappingItem();
                    item.Id = MappingController.SaveMapping(item);
                    //change a value
                    item.MappingPropertyAssociation.DestinationProperty = "Updated";

                    MappingController.SaveMapping(item);
                }
                catch (DiscoveryException e)
                {
                    Assert.IsInstanceOfType(typeof(ConcurrencyException), e.InnerException);
                    throw e;
                }
            }
        }
Exemple #4
0
        public void UpdateItem()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                if (MappingController.DeleteAllMappings())
                {
                    if (MappingController.DeleteAllMappingSystems())
                    {
                        if (MappingController.DeleteAllMappingPropertyAssociations())
                        {
                            if (MappingController.DeleteAllMappingClassAssociations())
                            {
                                Mapping item = PopulateMappingItem();
                                item.SourceValue = "Original";
                                item.Id          = MappingController.SaveMapping(item);
                                item             = GetItem(item.Id);
                                //change a value
                                item.SourceValue = "Updated";

                                MappingController.SaveMapping(item);
                                item = GetItem(item.Id);
                                Assert.IsTrue(item.SourceValue == "Updated");
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public void SaveMappingTestConstraint()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                MappingController.DeleteAllMappings();
                MappingController.DeleteAllMappingSystems();
                MappingController.DeleteAllMappingPropertyAssociations();
                MappingController.DeleteAllMappingClassAssociations();
                Mapping mapping = PopulateMappingItem();

                MappingController.SaveMapping(mapping);

                MappingController.SaveMapping(mapping);
            }
        }
Exemple #6
0
        public void DeleteAllMappings()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                MappingController.DeleteAllMappings();
                MappingController.DeleteAllMappingSystems();
                MappingController.DeleteAllMappingPropertyAssociations();
                MappingController.DeleteAllMappingClassAssociations();

                Mapping mapping = PopulateMappingItem();
                int     id      = MappingController.SaveMapping(mapping);
                Assert.IsTrue(id != -1);
                Assert.IsTrue(MappingController.DeleteAllMappings());
            }
        }
Exemple #7
0
        public void GetItem()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                if (MappingController.DeleteAllMappings())
                {
                    if (MappingController.DeleteAllMappingSystems())
                    {
                        if (MappingController.DeleteAllMappingPropertyAssociations())
                        {
                            if (MappingController.DeleteAllMappingClassAssociations())
                            {
                                int id = MappingController.SaveMapping(PopulateMappingItem());

                                Assert.IsNotNull(GetItem(id));
                            }
                        }
                    }
                }
            }
        }
Exemple #8
0
        public void Map()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                if (MappingController.DeleteAllMappings())
                {
                    if (MappingController.DeleteAllMappingSystems())
                    {
                        if (MappingController.DeleteAllMappingPropertyAssociations())
                        {
                            if (MappingController.DeleteAllMappingClassAssociations())
                            {
                                //add a mapping for route code
                                Mapping mapping;
                                mapping                  = PopulateMappingItem();
                                mapping.SourceValue      = "OpcoValue";
                                mapping.DestinationValue = "TDCValue";
                                MappingController.SaveMapping(mapping);


                                //set up source object to map to destination
                                OpCoShipment sourceObject = OpcoShipmentTests.PopulateNewItem();
                                sourceObject.RouteCode = mapping.SourceValue;

                                //set up a new instance of a TDC shipment to map the new values into
                                TDCShipment destinationObject = new TDCShipment();

                                //perform the mapping
                                MappingController.Map(sourceObject, destinationObject, mapping.SourceSystem.Name, mapping.DestinationSystem.Name, DoLines);


                                Assert.IsTrue
                                (
                                    destinationObject.GetType().GetProperty(mapping.MappingPropertyAssociation.DestinationProperty).
                                    GetValue(destinationObject,
                                             null).Equals(
                                        mapping.DestinationValue) &&
                                    ((sourceObject.ShipmentLines == null || sourceObject.ShipmentLines.Count == 0) || destinationObject.ShipmentLines.Count > 0) &&
                                    ((destinationObject.ShipmentLines == null || destinationObject.ShipmentLines.Count == 0) || destinationObject.ShipmentLines[0] is TDCShipmentLine) &&
                                    ((sourceObject.ShipmentLines == null || sourceObject.ShipmentLines.Count == 0) || sourceObject.ShipmentLines[0].ConversionQuantity == destinationObject.ShipmentLines[0].ConversionQuantity) &&
                                    sourceObject.CustomerAddress != null &&
                                    sourceObject.OpCoContact != null &&
                                    sourceObject.AfterTime == destinationObject.AfterTime &&
                                    sourceObject.BeforeTime == destinationObject.BeforeTime &&
                                    sourceObject.CheckInTime == destinationObject.CheckInTime &&
                                    sourceObject.CustomerAddress.Line1 == destinationObject.CustomerAddress.Line1 &&
                                    sourceObject.CustomerName == destinationObject.CustomerName &&
                                    sourceObject.CustomerNumber == destinationObject.CustomerNumber &&
                                    sourceObject.CustomerReference == destinationObject.CustomerReference &&
                                    sourceObject.DeliveryWarehouseCode == destinationObject.DeliveryWarehouseCode &&
                                    sourceObject.DespatchNumber == destinationObject.DespatchNumber &&
                                    sourceObject.DivisionCode == destinationObject.DivisionCode &&
                                    sourceObject.GeneratedDateTime == destinationObject.GeneratedDateTime &&
                                    sourceObject.Instructions == destinationObject.Instructions &&
                                    sourceObject.OpCoCode == destinationObject.OpCoCode &&
                                    sourceObject.OpCoContact.Email == destinationObject.OpCoContact.Email &&
                                    sourceObject.OpCoHeld == destinationObject.OpCoHeld &&
                                    sourceObject.OpCoSequenceNumber == destinationObject.OpCoSequenceNumber &&
                                    sourceObject.RequiredShipmentDate == destinationObject.RequiredShipmentDate &&
                                    // sourceObject.RouteCode == destinationObject.RouteCode &&
                                    sourceObject.SalesBranchCode == destinationObject.SalesBranchCode &&

                                    sourceObject.ShipmentName == destinationObject.ShipmentName &&
                                    sourceObject.ShipmentNumber == destinationObject.ShipmentNumber &&
                                    sourceObject.Status == destinationObject.Status &&
                                    sourceObject.StockWarehouseCode == destinationObject.StockWarehouseCode &&
                                    sourceObject.TailLiftRequired == destinationObject.TailLiftRequired &&
                                    sourceObject.TotalLineQuantity == destinationObject.TotalLineQuantity &&
                                    sourceObject.TransactionTypeCode == destinationObject.TransactionTypeCode &&
                                    sourceObject.VehicleMaxWeight == destinationObject.VehicleMaxWeight
                                );
                            }
                        }
                    }
                }
            }
        }