public void Group_Has_Invalid_Name() { ApplicationServices appServ = new ApplicationServices(); Group d = new Group("Group D", new Point(10, 10), 1); appServ.AddGroup(d); Group e = new Group("Group D", new Point(100, 100), 1); appServ.AddGroup(e); }
public void Group_Is_Invalid_Intersect() { ApplicationServices appServ = new ApplicationServices(); Group b = new Group("Group B", new Point(3, 3), 1); appServ.AddGroup(b); Group c = new Group("Group C", new Point(4, 4), 2); appServ.AddGroup(c); }
/// <summary> /// Handles the creation of groups based on the input file. It loops through every line read from the file manager, split the lines marked as Group /// using the passed delimiter and feed the list of arguments to the factory to receive a Group object. /// After that it sends the object to the service layer to be persisted. /// It set the index of the other lines, that are not marked as Group, so assumed to be Wells, asside so the next function, /// control the creation of Wells don't have to loop through the whole file. /// Although in theory both loops will be O(n), the loop used in <see cref="CreateWells(string[], char, List{int})"/> will actually be O(m) where m ⊆ n. /// After a group has been loaded the operation is logged in the logger as either a success or a fail with an appropriated message. /// </summary> /// <param name="lines">The lines read from the input file</param> /// <param name="delimiter">The delimiter used in the file</param> /// <returns>The list containing the index of all the lines that are not groups, assumed here to be Wells</returns> private static List <int> CreateGroups(String[] lines, char delimiter) { ApplicationServices appServ = new ApplicationServices(); Logger logger = Logger.GetInstance(); List <int> wIndexs = new List <int>(); for (int i = 0; i < lines.Length; i++) { //Split the line with the given delimiter, isolation the potential object's attributes String[] args = lines[i].Split(delimiter); if (String.Equals(args[0], "Group", StringComparison.OrdinalIgnoreCase)) { try { Group g = Factory.CreateGroup(args); appServ.AddGroup(g); logger.add(lines[i], "Loaded successfully"); } catch (CustomException e) { logger.add(lines[i], e.Message); } } else { wIndexs.Add(i); } } return(wIndexs); }
public void Well_Has_Valid_Name_Across_Groups() { ApplicationServices appServ = new ApplicationServices(); Group x = new Group("Group X", new Point(110, 110), 1); Well a = new Well("Well A", new Point(110, 110), new Point(1, 1)); Group y = new Group("Group Y", new Point(120, 120), 1); Well b = new Well("Well A", new Point(120, 120), new Point(1, 1)); try { appServ.AddGroup(x); appServ.AddGroup(y); appServ.AddWell(a); appServ.AddWell(b); }catch (Exception e) { Assert.Fail("Expected no error, got " + e.Message); } }
public void Group_Is_Added() { ApplicationServices appServ = new ApplicationServices(); Group a = new Group("Group A", new Point(1, 1), 1); appServ.AddGroup(a); int expected = 1; int actual = appServ.GetGroups().Count; 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); }