예제 #1
0
        // GET: Admin/RealStates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RealState realState = _realStateRepo.Get(id.Value);

            if (realState == null)
            {
                return(HttpNotFound());
            }

            var selectedCity    = _geoDivisionRepo.Get(realState.GeoDivisionId);
            var selectedState   = _geoDivisionRepo.GetGeoDivisionParent(selectedCity.ParentId.Value);
            var selectedCountry = _geoDivisionRepo.GetGeoDivisionParent(selectedState.ParentId.Value);

            ViewBag.SelectedState   = selectedState.Id;
            ViewBag.SelectedCountry = selectedCountry.Id;
            ViewBag.States          = _geoDivisionRepo.GetGeoDivisionChildren(selectedCountry.Id);
            ViewBag.Cities          = _geoDivisionRepo.GetGeoDivisionChildren(selectedState.Id);
            ViewBag.Countries       = _geoDivisionRepo.GetCountries();

            return(View(realState));
        }
예제 #2
0
        public void TestRunWinner()
        {
            //Arrange
            Player    p1   = new Player(100);
            Player    p2   = new Player(0);
            RealState r    = new RealState(100, 10);
            var       mock = new Mock <IDice>();

            mock.Setup(s => s.Roll()).Returns(1);
            var  dice = mock.Object;
            Game g    = new Game(new List <Player>()
            {
                p1, p2
            },
                                 new List <RealState>()
            {
                r
            },
                                 dice);

            //Act
            Player winner = g.Run();

            //Assert
            Assert.AreEqual(p1, winner);
        }
예제 #3
0
 public double GetPower(RealState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     return((state.Solution[_posNode] - state.Solution[_negNode]) * -Current);
 }
예제 #4
0
 public double GetCurrent(RealState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     return((state.Solution[_posNode] - state.Solution[_negNode]) * _temp.Conductance);
 }
예제 #5
0
 public double GetVoltage(RealState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     return(state.Solution[_posNode] - state.Solution[_negNode]);
 }
예제 #6
0
        public double GetCurrent(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return(state.Solution[BranchEq]);
        }
예제 #7
0
        public double GetPower(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return(QCap.Derivative * (state.Solution[_posNode] - state.Solution[_negNode]));
        }
예제 #8
0
        public double GetPower(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return((state.Solution[_posNode] - state.Solution[_negNode]) * state.Solution[ControlBranchEq] * _bp.Coefficient);
        }
예제 #9
0
        public double GetCurrent(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return(state.Solution[ControlBranchEq] * _bp.Coefficient);
        }
예제 #10
0
        public void TestNotHasOwner()
        {
            //Arrange
            RealState r = new RealState(50, 5);

            //Act

            //Assert
            Assert.IsFalse(r.HasOwner());
        }
예제 #11
0
        public double GetPower(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            double v = state.Solution[_posNode] - state.Solution[_negNode];

            return(v * v * _bp.Coefficient);
        }
예제 #12
0
        public void TestRentIsOwner()
        {
            //Arrange
            Player    p1 = new Player(5);
            RealState r  = new RealState(50, 5, owner: p1);

            //Act
            r.RentTo(p1);

            //Assert
            Assert.AreEqual(5, p1.Balance);
        }
예제 #13
0
        public void TestInit()
        {
            //Arrange
            RealState r = new RealState(50, 5);

            //Act

            //Assert
            Assert.AreEqual(50, r.Price);
            Assert.AreEqual(5, r.Rent);
            Assert.IsNull(r.Owner);
        }
예제 #14
0
        public void TestHasOwner()
        {
            //Arrange
            Player    p = new Player(0);
            RealState r = new RealState(50, 5, owner: p);

            //Act

            //Assert
            Assert.IsTrue(r.HasOwner());
            Assert.AreEqual(p, r.Owner);
        }
예제 #15
0
        public void TestForeclose()
        {
            //Arrange
            Player    p = new Player(0);
            RealState r = new RealState(50, 5, owner: p);

            //Act
            r.Foreclose();

            //Assert
            Assert.IsFalse(r.HasOwner());
        }
예제 #16
0
        public Complex GetPower(RealState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            Complex v = state.Solution[_posNode] - state.Solution[_negNode];
            Complex i = state.Solution[_contBranch] * _bp.Coefficient.Value;

            return(-v *Complex.Conjugate(i));
        }
예제 #17
0
        public void TestSellError()
        {
            //Arrange
            Player    p1 = new Player(100);
            Player    p2 = new Player(100);
            RealState r  = new RealState(50, 5, owner: p1);

            //Act


            //Assert
            Assert.Throws <RealState.SellException>(() => r.SellTo(p2));
        }
예제 #18
0
        public void TestHasOwnedBy()
        {
            //Arrange
            Player    p1 = new Player(0);
            Player    p2 = new Player(0);
            RealState r  = new RealState(50, 5, owner: p1);

            //Act

            //Assert
            Assert.IsTrue(r.OwnerIs(p1));
            Assert.IsFalse(r.OwnerIs(p2));
        }
예제 #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="inductance">Inductor</param>
        /// <param name="current">Current</param>
        /// <param name="flux">Flux</param>
        /// <param name="state">State</param>
        public UpdateFluxEventArgs(double inductance, double current, StateDerivative flux, RealState state)
        {
            if (flux == null)
            {
                throw new ArgumentNullException(nameof(flux));
            }

            Inductance   = inductance;
            Current      = current;
            OriginalFlux = flux.Current;
            Flux         = flux;
            State        = state ?? throw new ArgumentNullException(nameof(state));
        }
예제 #20
0
        public void TestDealSell()
        {
            //Arrange
            Player    p1 = new Player(100);
            RealState r  = new RealState(50, 5);

            //Act
            r.Deal(p1);

            //Assert
            Assert.IsTrue(r.OwnerIs(p1));
            Assert.AreEqual(50, p1.Balance);
        }
예제 #21
0
        public ActionResult Create(RealState realState, HttpPostedFileBase RealStateImage, HttpPostedFileBase VideoImage, HttpPostedFileBase Video)
        {
            realState.LastViewDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                #region Upload Files
                if (RealStateImage != null)
                {
                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(RealStateImage.FileName);
                    RealStateImage.SaveAs(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName));
                    // Resize Image
                    ImageResizer big = new ImageResizer(2000, 2000, true);
                    big.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName),
                               Server.MapPath("/Files/RealStateImages/Big/" + newFileName));

                    ImageResizer image = new ImageResizer(370, 270, true);
                    image.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/RealStateImages/" + newFileName));
                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName));

                    realState.Image = newFileName;
                }
                if (VideoImage != null)
                {
                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(VideoImage.FileName);
                    VideoImage.SaveAs(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName));
                    // Resize Image
                    ImageResizer image = new ImageResizer(870, 500, true);
                    image.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/RealStateImages/VideoImages/" + newFileName));
                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName));

                    realState.VideoThumbnail = newFileName;
                }
                if (Video != null)
                {
                    var newFileName = Guid.NewGuid() + Path.GetExtension(Video.FileName);
                    Video.SaveAs(Server.MapPath("/Files/RealStateImages/Videos/" + newFileName));
                    realState.VideoStr = newFileName;
                }
                #endregion

                _realStateRepo.Add(realState);
                return(RedirectToAction("Index"));
            }
            return(View(realState));
        }
예제 #22
0
        public void TestSell()
        {
            //Arrange
            Player    p = new Player(100);
            RealState r = new RealState(50, 5);

            //Act
            r.SellTo(p);

            //Assert
            Assert.IsTrue(r.HasOwner());
            Assert.IsTrue(r.OwnerIs(p));
            Assert.AreEqual(50, p.Balance);
        }
예제 #23
0
        // GET: Admin/RealStates/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RealState realState = _realStateRepo.Get(id.Value);

            if (realState == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(realState));
        }
예제 #24
0
        public void TestSize()
        {
            //Arrange
            RealState r = new RealState(100, 10);
            Board     b = new Board(new List <Player>(), new List <RealState>()
            {
                r
            });

            //Act

            //Assert
            Assert.AreEqual(1, b.Size);
        }
예제 #25
0
        public void TestDealRent()
        {
            //Arrange
            Player    p1 = new Player(100);
            Player    p2 = new Player(0);
            RealState r  = new RealState(50, 5, owner: p2);

            //Act
            r.Deal(p1);

            //Assert
            Assert.AreEqual(95, p1.Balance);
            Assert.AreEqual(5, p2.Balance);
        }
예제 #26
0
        public void TestTieAgain()
        {
            //Arrange
            List <Player> players = Player.FromStrategies(0);
            RealState     r       = new RealState(100, 10);
            Game          g       = new Game(players, new List <RealState>()
            {
                r
            });

            //Act

            //Assert
            Assert.AreEqual(players[0], g.Leader);
        }
예제 #27
0
        public void TestInit()
        {
            //Arrange
            List <Player> players = Player.FromStrategies(300);
            RealState     r       = new RealState(100, 10);
            Game          g       = new Game(players, new List <RealState>()
            {
                r
            });

            //Act

            //Assert
            players.ForEach(p => Assert.IsTrue(p.Balance == 300));
            Assert.IsNotNull(g.Board);
        }
예제 #28
0
        public void TestLeader()
        {
            //Arrange
            List <Player> players = Player.FromStrategies(0);
            RealState     r       = new RealState(100, 10);
            Game          g       = new Game(players, new List <RealState>()
            {
                r
            });

            //Act
            players[0].Receive(1);
            players[1].Receive(2);
            players[2].Receive(3);

            //Assert
            Assert.AreEqual(players[2], g.Leader);
        }
예제 #29
0
        public void TestRemove()
        {
            //Arrange
            Player    p = new Player(0);
            RealState r = new RealState(100, 10);
            Board     b = new Board(new List <Player>()
            {
                p
            }, new List <RealState>()
            {
                r
            });

            //Act
            b.Remove(p);

            //Assert
            Assert.AreEqual(0, b.Players.Count);
        }
예제 #30
0
        public RealStateInfoDto CreateRealStateInfo(RealState realState)
        {
            var plan = GetRealStatePlanWithLowestPrice(realState.Id);
            var info = new RealStateInfoDto()
            {
                Id               = realState.Id,
                Title            = _currentLang == 1 ? realState.Title : realState.EnglishTitle,
                ShortDescription = _currentLang == 1 ? realState.ShortDescription : realState.EnglishShortDescription,
                Area             = plan.Area,
                Rooms            = plan.Rooms,
                Bathrooms        = plan.BathRooms,
                MinPrice         = CurrencyHelper.ExchangeAmount(plan.Price, _currentCurrency),
                Location         = GetLocationStr(realState.GeoDivisionId),
                RealStateType    = realState.Type,
                Image            = realState.Image
            };

            return(info);
        }