Beispiel #1
0
        /// <summary>
        /// Validate the passed well against the business rules
        /// </summary>
        /// <exception cref="DuplicatedWellNameException">Thrown when this Well has the same Unique Name as another Well already added to the list</exception>
        /// <exception cref="DuplicateWellLocationException">Thrown when this Well has the same location of another Well already added to the list</exception>
        /// <param name="toAdd">The group to be validated</param>
        private void ValidateWell(Well toAdd)
        {
            foreach (Well w in app.GetWells())
            {
                //Validate if uniqueName is unique
                if (w.GetUniqueName().Equals(toAdd.GetUniqueName()))
                {
                    throw new DuplicatedWellNameException($"{toAdd.GetUniqueName()} already exists");
                }

                //Validate if location is unique
                if (w.GetTopHole().Equals(toAdd.GetTopHole()))
                {
                    throw new DuplicateWellLocationException($"{toAdd.GetUniqueName()} in same location as {w.GetUniqueName()}");
                }
            }
        }
        public void Well_Is_Orphan()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well x = new Well("Well X", new Point(1000, 1000), new Point(1, 1));

            appServ.AddWell(x);
            bool expected = true;
            bool actual   = x.GetUniqueName().Contains("Orphan");

            Assert.AreEqual(expected, actual);
        }
        public void Well_Belong_To_Group()
        {
            ApplicationServices appServ = new ApplicationServices();
            Group zed = new Group("Group Z", new Point(1010, 1010), 1);

            appServ.AddGroup(zed);
            Well z = new Well("Well Z", new Point(1010, 1010), new Point(1, 1));

            appServ.AddWell(z);
            bool expected = true;
            bool actual   = z.GetUniqueName().Contains("Group Z");

            Assert.AreEqual(expected, actual);
        }
        public void Orphan_Well_Is_Reassigned()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well g = new Well("Well G", new Point(2000, 2000), new Point(1, 1));

            appServ.AddWell(g);
            Group ge = new Group("Group G", new Point(2000, 2000), 1);

            appServ.AddGroup(ge);
            appServ.CheckOrphanWells();

            bool expected = true;
            bool actual   = g.GetUniqueName().Contains("Group G");

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
 /// <summary>
 /// Assign the passed Well to one of the groups added or to the default group if this Well don't reside inside any of the known groups.
 /// It also adds the well to the group's children list
 /// </summary>
 /// <param name="w">The Well to be analyzed</param>
 private void AssignWellToGroup(Well w)
 {
     foreach (Group g in app.GetGroups())
     {
         if (w.IsInside(g))
         {
             String uniqueName = g.GetName() + w.GetName();
             w.SetUniqueName(uniqueName);
             g.AddChild(w);
             break;
         }
     }
     if (w.GetUniqueName() == null)
     {
         w.SetUniqueName(DEFAULT_GROUP_NAME + w.GetName());
     }
 }