public void AddConnectionBetweenTest() { Area a = AreaFactory.Rectangle("test-tangle", new Coord(0, 0), 6, 6); Area b = AreaFactory.Rectangle("rest-ert", new Coord(a.Right, a.Top), 5, 5); int aCountBefore = a.OuterPoints.Count(); int bCountBefore = b.OuterPoints.Count(); Area.AddConnectionBetween(a, b); Assert.AreEqual(1, a.Connections.Count()); Assert.AreEqual(1, b.Connections.Count()); Assert.AreEqual(aCountBefore - 1, a.OuterPoints.Count()); Assert.AreEqual(bCountBefore - 1, b.OuterPoints.Count()); }
public void RemoveOverlappingPointsTest() { Area a = AreaFactory.FromRectangle("Area A", new Rectangle(new Coord(3, 3), new Coord(5, 5))); Area b = AreaFactory.FromRectangle("Area B", new Rectangle(new Coord(1, 1), new Coord(7, 7))); int bCountBefore = b.OuterPoints.Count(); a.RemoveOverlappingPoints(b); Assert.AreEqual(0, a.OuterPoints.Count()); Assert.AreEqual(0, a.InnerPoints.Count()); Assert.AreEqual(b.OuterPoints.Count(), bCountBefore, "Connecting points were unexpectedly removed from Area b"); }
public static void FromRectangleTest() { Rectangle rectangle = new Rectangle(new Coord(1, 1), new Coord(5, 5)); Area area = AreaFactory.FromRectangle("square", rectangle); //Assert.AreEqual(25, area.OuterPoints.Count()); Assert.AreEqual(rectangle.Width, area.Width); Assert.AreEqual(rectangle.Height, area.Height); Assert.AreEqual(20, area.OuterPoints.Count()); Assert.AreEqual(6, area.NorthBoundary.Count()); Assert.AreEqual(6, area.SouthBoundary.Count()); Assert.AreEqual(6, area.EastBoundary.Count()); Assert.AreEqual(6, area.WestBoundary.Count()); }
public void CreateNonexistentRoomsUsingAreaFactoryAndRealDLL() { // arrange IArea expected; IArea gotten; AreaFactory areaFactory = new AreaFactory(); //act expected = new ActualPool.ActualPool(); gotten = areaFactory.GetArea("ActualPool"); //assert Assert.AreEqual(expected.GetType(), gotten.GetType()); }
public void CreateNonexistentRoomsUsingAreaFactoryAndFakeDLL() { // arrange IArea expected; IArea gotten; AreaFactory areaFactory = new AreaFactory(); //act expected = null; gotten = areaFactory.GetArea("Pool"); //assert Assert.AreEqual(expected, gotten); }
public void Create_ExistingKey() { //arrange AreaFactory areaFactory = new AreaFactory(); Room room = new Room(); Type expected = room.GetType(); areaFactory.internalFactory.Add <Room>("key"); IArea actual; //act actual = areaFactory.Create("key"); //assert Assert.IsInstanceOfType(actual, expected); }
private List <AreaType> getUnavailableAreas(AreaDbContext DB, string username) { List <AreaType> unavailable_areatypes = new List <AreaType>(); List <AreaType> all_areatypes = DB.areatypes.ToList(); AREA tmp = new AREA(); tmp.username = username; tmp.index_action = 0; tmp.index_reaction = 0; tmp.last_event = ""; foreach (var area_type in all_areatypes) { tmp.type = area_type.id; IArea type = AreaFactory.create(tmp, DB); if (type != null && !type.isAvailable()) { unavailable_areatypes.Add(area_type); } } return(unavailable_areatypes); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, PhoneNumber = model.PhoneNumber }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); var role = await this.UserManager.AddToRoleAsync(user.Id, model.UserRole); //if (!model.UserRole.Equals("Buyer")) // return RedirectToAction("Dashboard", "AdminLte", new { area = "" }); //else // return RedirectToAction("AddAddress", "Consumer", new { area = "Consumer", id = user.Id }); AreaFactory GotoArea = new AreaFactory(); return(GotoArea.GetArea(model.UserRole).RedirectToArea(model.UserRole)); } AddErrors(result); } ViewBag.UserRole = new SelectList(db.Roles.Where(u => !u.Name.Contains("Admin")) .ToList().OrderBy(x => x.Name), "Name", "Name"); // If we got this far, something failed, redisplay form return(View(model)); }
public void runAreas(object Db) { try { AreaDbContext DB = (AreaDbContext)Db; while (true) { foreach (var area in DB.areas.ToList()) { IArea ar = AreaFactory.create(area, DB); if (ar != null) { ar.run(DB); } } Thread.Sleep(10000); } } catch (Exception e) { Console.WriteLine("Message: " + e.Message); Console.WriteLine("Source: " + e.Source); System.Environment.Exit(0); } }