Beispiel #1
0
        public void SaveAs_Bid_SubScopeConnection()
        {
            //Arrange
            TECController          expectedConnectedController = null;
            TECHardwiredConnection expectedConnection          = null;

            foreach (TECController controller in expectedBid.Controllers)
            {
                foreach (IControllerConnection connection in controller.ChildrenConnections)
                {
                    if (connection is TECHardwiredConnection)
                    {
                        expectedConnectedController = controller;
                        expectedConnection          = connection as TECHardwiredConnection;
                        break;
                    }
                }
                if (expectedConnectedController != null)
                {
                    break;
                }
            }
            TECController          actualConnectedController = actualBid.FindChild(expectedConnectedController.Guid) as TECController;
            TECHardwiredConnection actualConnection          = actualConnectedController.FindChild(expectedConnection.Guid) as TECHardwiredConnection;

            //Assert
            Assert.AreEqual(expectedConnection.Guid, actualConnection.Guid);
            Assert.AreEqual(expectedConnection.ConduitType.Guid, actualConnection.ConduitType.Guid);
            Assert.AreEqual(expectedConnection.Length, actualConnection.Length, DELTA);
            Assert.AreEqual(expectedConnection.ParentController.Guid, actualConnection.ParentController.Guid);
            Assert.AreEqual(expectedConnection.Child.Guid, actualConnection.Child.Guid);
            Assert.IsTrue(compareCosts(expectedConnection.CostBatch, actualConnection.CostBatch));
            //Assert.IsFalse(actualConnection.IsTypical);
        }
Beispiel #2
0
        public void SaveAs_Bid_SubScope()
        {
            //Arrange
            TECBid bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand, 5);
            TECTypical   system            = new TECTypical();
            TECEquipment expectedEquipment = new TECEquipment();
            TECSubScope  expectedSubScope  = ModelCreation.TestSubScope(bid.Catalogs, rand);

            expectedEquipment.SubScope.Add(expectedSubScope);
            system.Equipment.Add(expectedEquipment);

            bid.Systems.Add(system);

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            TECSubScope actualSubScope = loadedBid.FindChild(expectedSubScope.Guid) as TECSubScope;

            //Assert
            Assert.AreEqual(expectedSubScope.Name, actualSubScope.Name);
            Assert.AreEqual(expectedSubScope.Description, actualSubScope.Description);
            Assert.AreEqual(expectedSubScope.Interlocks.Count, actualSubScope.Interlocks.Count);
            Assert.AreEqual(expectedSubScope.ScopeBranches.Count, actualSubScope.ScopeBranches.Count);
            Assert.IsTrue(compareCosts(expectedSubScope.CostBatch, actualSubScope.CostBatch));
        }
Beispiel #3
0
 public void addToCost(Dictionary <Guid, INotifyCostChanged> costDictionary, ITECObject item, TECBid referenceBid)
 {
     if (item is TECCatalogs)
     {
         return;
     }
     if (item is INotifyCostChanged costItem)
     {
         if (referenceBid.FindChild(item.Guid) == null)
         {
             var errant = item;
             throw new Exception();
         }
         costDictionary[item.Guid] = costItem;
     }
     if (item is IRelatable saveable)
     {
         foreach (ITECObject child in saveable.GetDirectChildren())
         {
             addToCost(costDictionary, child, referenceBid);
         }
     }
 }
Beispiel #4
0
        public static void ClassInitialize(TestContext TestContext)
        {
            rand = new Random(0);
            //Arrange
            expectedBid        = ModelCreation.TestBid(rand);
            expectedLabor      = expectedBid.ExtraLabor;
            expectedParameters = expectedBid.Parameters;
            expectedSystem     = expectedBid.Systems.First(x => x.Location != null);
            expectedSystem1    = expectedBid.Systems.First(x => x != expectedSystem);

            expectedEquipment = expectedSystem.Equipment.First(x => x.SubScope.Count > 0 && x.Location != null);
            expectedSubScope  = expectedEquipment.SubScope.First(x => x.Location != null);
            expectedDevice    = expectedBid.Catalogs.Devices.Where(x => x.Tags.Count > 0).First();

            expectedManufacturer = expectedDevice.Manufacturer;
            expectedPoint        = expectedSubScope.Points[0];

            expectedBranch    = expectedBid.ScopeTree.First(x => x.Branches.Count > 0 && x.Branches[0].Branches.Count > 0);
            expectedNote      = expectedBid.Notes[0];
            expectedExclusion = expectedBid.Exclusions[0];
            expectedTag       = expectedBid.Catalogs.Tags[0];

            expectedController = (TECProvidedController)expectedBid.Controllers.First(item => item is TECProvidedController);

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(expectedBid);
            actualBid = manager.Load();

            if (actualBid.Systems.Count == 0)
            {
                string failDirectory = Path.GetTempPath() + "Estimating Tools\\";
                Directory.CreateDirectory(failDirectory);
                string failPath = failDirectory + "SaveNewBidTestFailed.edb";
                if (File.Exists(failPath))
                {
                    File.Delete(failPath);
                }
                File.Copy(path, failPath);
                Assert.Fail(string.Format("No systems loaded into bid. File saved at: {0}", failPath));
            }

            actualLabor          = actualBid.ExtraLabor;
            actualBid.Parameters = actualBid.Parameters;
            actualSystem         = actualBid.FindChild(expectedSystem.Guid) as TECTypical;
            actualSystem1        = actualBid.FindChild(expectedSystem1.Guid) as TECTypical;
            actualEquipment      = actualBid.FindChild(expectedEquipment.Guid) as TECEquipment;
            actualSubScope       = actualBid.FindChild(expectedSubScope.Guid) as TECSubScope;
            actualDevices        = actualSubScope.Devices;
            actualDevice         = actualBid.FindChild(expectedDevice.Guid) as TECDevice;
            actualPoint          = actualBid.FindChild(expectedPoint.Guid) as TECPoint;
            actualManufacturer   = actualBid.FindChild(expectedManufacturer.Guid) as TECManufacturer;
            actualBranch         = actualBid.FindChild(expectedBranch.Guid) as TECScopeBranch;
            actualNote           = actualBid.FindChild(expectedNote.Guid) as TECLabeled;
            actualExclusion      = actualBid.FindChild(expectedExclusion.Guid) as TECLabeled;
            actualTag            = actualBid.FindChild(expectedTag.Guid) as TECTag;
            actualController     = actualBid.FindChild(expectedController.Guid) as TECProvidedController;
        }