예제 #1
0
        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());
        }
예제 #2
0
        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");
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }
예제 #5
0
        public void CreateNonexistentRoomsUsingAreaFactoryAndFakeDLL()
        {
            // arrange
            IArea       expected;
            IArea       gotten;
            AreaFactory areaFactory = new AreaFactory();

            //act
            expected = null;

            gotten = areaFactory.GetArea("Pool");

            //assert
            Assert.AreEqual(expected, gotten);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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));
        }
예제 #9
0
 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);
     }
 }