Esempio n. 1
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            Corporation corporation = (Corporation)Session["corporation"];
            CorSelfBooktypeTableAdapter ta_booktype = new CorSelfBooktypeTableAdapter();

            //查询选择的节点,得到选择节点的id
            if (this.tree.SelectedNode == null)
            {
                lab_tip.Text = "没有选中目录";
            }
            else
            {
                DataTable dt_booktype = ta_booktype.GetSelfBooktypeByName(this.tree.SelectedNode.Value, corporation.id);
                int       parent_id   = Convert.ToInt32(dt_booktype.Rows[0]["id"]);
                dt_booktype = ta_booktype.GetSelfBooktypeByName(txt_name.Text, corporation.id);
                if (dt_booktype.Rows.Count != 0)
                {
                    lab_tip.Text = "账户名已存在";
                }
                else
                {
                    if (txt_name.Text == "")
                    {
                        lab_tip.Text = "输入不能为空";
                    }
                    else
                    {
                        ta_booktype.InsertSSelfBooktype(txt_name.Text, 0, parent_id, corporation.id);
                        lab_tip.Text = "添加成功";
                    }
                }
            }
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CorporationDetails_layout);

            playerRepo = PlayersRepositoryService.Instance;
            gameRepo   = GameRepositoryService.Instance;
            gameId     = Intent.GetIntExtra("gameId", 1);

            isExisting = Intent.GetBooleanExtra("isExisting", false);
            if (isExisting)
            {
                existingPlayerName  = Intent.GetStringExtra("playerName");
                existingGameId      = Intent.GetIntExtra("GameID", 0);
                existingCorporation = gameRepo.GetCorporation(existingGameId, existingPlayerName);
            }

            ConnectViews();

            if (isExisting)
            {
                SetupExistingCorporationValues();
                playerLayout.Visibility = ViewStates.Gone;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 修改公司
        /// </summary>
        /// <param name="request"></param>
        /// <param name="loginUser"></param>
        /// <returns>true:修改成功,false:修改失败</returns>
        public WebFxsResult <bool> EditCorporation(EditCorporationRQ request, User loginUser)
        {
            var result = new WebFxsResult <bool>
            {
                ReturnCode = ReturnCodeType.Error,
                Content    = false
            };

            var item = new Corporation
            {
                Id              = request.Id,
                Name            = request.Name,
                Sort            = request.Sort,
                LastUpdatedBy   = loginUser.UserId,
                LastUpdatedTime = DateTime.Now
            };
            var rs = Update(item);

            if (rs == true)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = rs;
            }

            return(result);
        }
Esempio n. 4
0
        public Task <OperateResultRsp> RegisterCorporation(CorpEditReq req)
        {
            //是否已经被注册?
            var existCorp = _queryCorpRepository.Exist(a => !a.IsDelete && a.Name == req.CorpName);

            if (!existCorp)
            {
                var aCorp = new Corporation
                {
                    CorporationKeyId = Guid.NewGuid(),
                    Name             = req.CorpName,
                    No         = req.CorpName,
                    Version    = 1,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now,
                    IsDelete   = false
                };
                _repository.Add(aCorp);
                _repository.Commit();
                return(Task.FromResult(new OperateResultRsp
                {
                    OperateFlag = true,
                    OperateResult = "注册成功"
                }));
            }
            else
            {
                return(Task.FromResult(new OperateResultRsp
                {
                    OperateFlag = false,
                    OperateResult = "该企业已经被注册"
                }));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 添加公司
        /// </summary>
        /// <param name="request"></param>
        /// <returns>返回新添加的公司</returns>
        public WebFxsResult <Corporation> AddCorporation(AddCorporationRQ request, User loginUser)
        {
            var result = new WebFxsResult <Corporation>
            {
                ReturnCode = ReturnCodeType.Error,
                Content    = new Corporation()
            };

            var item = new Corporation
            {
                Name        = request.Name,
                Code        = request.Code,
                ParentId    = request.ParentId,
                Sort        = request.Sort,
                Enabled     = true,             //默认启用
                CreatedBy   = loginUser.UserId, //当前登录人
                CreatedTime = DateTime.Now
            };
            var rs = Insert(item);

            if (rs != null)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = rs;
            }

            return(result);
        }
        public async Task ShouldAddCorporation()
        {
            // Arrange
            var playerId            = Guid.NewGuid();
            var expectedCorporation = new Corporation
            {
                CreatedByPlayerId = playerId,
                CorporationId     = Guid.NewGuid(),
                Name        = Guid.NewGuid().ToString(),
                Description = Guid.NewGuid().ToString(),
            };

            // Act
            await When(new PlayerCreatedEvent(new Player {
                PlayerId = playerId
            }));
            await When(new CorporationCreatedEvent(expectedCorporation, null));

            // Assert
            using (var dbContext = GetInMemoryDatabase())
            {
                Assert.NotEmpty(dbContext.Corporations);
                var corporation = dbContext.Corporations.First();
                Assert.Equal(expectedCorporation.CorporationId, corporation.CorporationId);
                Assert.Equal(expectedCorporation.Name, corporation.Name);
                Assert.Equal(expectedCorporation.Description, corporation.Description);
                Assert.Equal(0, corporation.Credits);
            }
        }
Esempio n. 7
0
 private void OnCorpChange(Corporation c)
 {
     if (null != _char && _char.Corp == c.ID && c.Loaded)
     {
         ICU.text = c.ICU.ToString() + " ICU";
     }
 }
Esempio n. 8
0
 protected corpRegistry(CorporationDB db, ItemFactory itemFactory, Corporation corp, int isMaster, BoundServiceManager manager, Client client) : base(manager, client)
 {
     this.DB           = db;
     this.ItemFactory  = itemFactory;
     this.mCorporation = corp;
     this.mIsMaster    = isMaster;
 }
Esempio n. 9
0
        public Corporation GetCorporationById(int id)
        {
            var corp = _context.Corporations.FirstOrDefault(x => x.Id == id);

            if (corp == null || corp.PassedMoreThan())
            {
                var esiResult = _corporationApi.GetCorporationsCorporationId(id, null, null);
                if (esiResult.AllianceId.HasValue)
                {
                    _allianceService.GetAllianceById(esiResult.AllianceId.Value);
                }
                if (corp == null)
                {
                    var newMask = new Mask();
                    _context.Masks.Add(newMask);
                    _context.SaveChanges();
                    corp = new Corporation
                    {
                        Id         = id,
                        Name       = esiResult.Name,
                        AllianceId = esiResult.AllianceId,
                        MaskId     = newMask.Id
                    };
                    _context.Corporations.Add(corp);
                    newMask.CorporationId = id;
                    _context.SaveChanges();
                }
                else
                {
                    corp.AllianceId = esiResult.AllianceId;
                }
            }
            _context.SaveChanges();
            return(corp);
        }
Esempio n. 10
0
        public async Task SimpleUpdateFromKey(long userid, long keyid, string vcode)
        {
            _logger.Debug("{method} {userid} {keyid}", "CorporationRepo::SimpleUpdateFromKey", userid, keyid);

            using (var ctx = _accountContextProvider.Context)
            {
                var corpos = (await GetAll(userid)).Select(x => x.EveId);
                var corpo  = _eveApi.GetCorporations(keyid, vcode);
                if (corpos.Contains(corpo.CorporationId))
                {
                    return;
                }

                var toadd = new Corporation()
                {
                    EveId     = corpo.CorporationId,
                    KeyInfoId = keyid,
                    Name      = corpo.CorporationName
                };

                ctx.Corporations.Add(toadd);

                await ctx.SaveChangesAsync();
            }
        }
Esempio n. 11
0
        public void ShipUnloadingSelling()
        {
            Universe        u      = new Universe(0);
            Station         city   = u.GetStation(1);
            Station         city2  = u.GetStation(2);
            Corporation     player = u.CreateCorp(1);
            Ship            ship   = city.CreateShip(player);
            ResourceElement e      = new ResourceElement(ResourceElement.ResourceType.Food, city2, 100, 1);
            ResourceStack   stack  = new ResourceStack(e);

            ship.Cargo.Add(stack);

            Hangar h = city.CreateHangar(player);

            ShipDestination dest = ship.AddDestination(city);

            dest.AddUnload(ResourceElement.ResourceType.Food, 100);
            ship.Start();

            //ca prend 10 fois pour decharger
            for (int i = 0; i < 11; i++)
            {
                u.Update();
            }

            Assert.AreEqual(0, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Food));
            Assert.AreEqual(15000, ship.Owner.ICU);
            Assert.AreEqual(100, city.GetHangar(-1).GetResourceQte(ResourceElement.ResourceType.Food));
        }
Esempio n. 12
0
        public void ShipLoading1()
        {
            Universe        u    = new Universe(0);
            Station         s    = u.GetStation(1);
            Station         s2   = u.GetStation(2);
            Corporation     corp = u.CreateCorp(1);
            Ship            ship = s.CreateShip(corp);
            Hangar          h    = s.CreateHangar(corp);
            ResourceElement e    = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 100, 1);

            h.Add(new ResourceStack(e));

            s.CreateHangar(corp);
            ShipDestination dest = ship.AddDestination(s);

            dest.AddLoad(ResourceElement.ResourceType.Wastes, 100);

            ShipDestination dest2 = ship.AddDestination(s2);

            ship.Start();

            for (int ite = 0; ite < 10; ite++)
            {
                u.Update();
            }

            Assert.AreEqual(100, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Wastes));

            u.Update(); //chargerment
            u.Update(); //sortie
            Assert.IsNull(ship.CurrentStation);
        }
    /// <summary>
    /// Buy # stock in the passed Corporation id
    /// TODO: Overload this with int[] id so that player can buy multiple at a time
    /// </summary>
    /// <param name="player">Player buying (ActivePlayer)</param>
    /// <param name="id">Corporation ID</param>
    /// <param name="amount">Amount to buy 1 or 2</param>
    public void BuyStock(Player player, int id, int amount = 1)
    {
        if (amount > 3)
        {
            Debug.Log("Tried to buy more than 3 stocks - that's cheating.");
            throw new System.Exception("Unable to purchase more than 3 stocks a turn.");
        }

        Corporation corp = Corporation(id);

        //Debug.Log("Player: " + player.Name + " is " + " buying " + amount.ToString() + " " + corp.Name +" stocks when " + corp.Name + " has " + corp.Stocks.Count + " stocks available");

        if (corp.Stocks.Count >= amount)
        {
            for (int i = 0; i < amount; ++i)
            {
                player.Stocks.Add(corp.Stocks.Pop());
            }

            ++GameManager.Instance.StocksPurchased;
            GameManager.Instance.MoneyController.SpendMoney(player, corp.StockValue);
            // TODO: Game Options
            //if (GameManager.Options.ShowPlayerStock)
            Debug.Log("Successfully bought stock, player's stock count: " + player.Stocks.Count.ToString());
            return;
        }

        throw new System.Exception("Something went wrong, there were no more stocks left.");
    }
Esempio n. 14
0
        public void AddCorporation(Corporation corporation)
        {
            var corporationJson = (CorporationJson)Self.GET(Utils.MakeUrl("partial/corporation/") + corporation.GetObjectID());

            corporationJson.RefreshFranchises(corporation.franchises);
            this.corporations.Add(corporationJson);
        }
Esempio n. 15
0
        public CorporationUserCreatedConfirmation CreateUser(Corporation user, string password)
        {
            if (!CheckUniqueUsername(user.Username, false, null))
            {
                //Unique violation
                throw new UniqueValueViolationException("Username should be unique");
            }
            if (!CkeckUniqueEmail(user.Email))
            {
                throw new UniqueValueViolationException("Email should be unique");
            }
            if (!CheckCity(user.CityId))
            {
                throw new ForeignKeyConstraintViolationException("Foreign key constraint violated");
            }
            CorporationUserCreatedConfirmation userCreated = _corporationUserRepository.CreateUser(user);

            _corporationUserRepository.SaveChanges();

            //Adding to identityuserdbcontext tables
            string         username = string.Join("", user.Username.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
            var            acc      = new AccountInfo(username, user.Email, userCreated.UserId);
            IdentityResult result   = _userManager.CreateAsync(acc, password).Result;

            if (result.Succeeded)
            {
                _userManager.AddToRoleAsync(acc, "Regular user").Wait();
            }
            else
            {
                _corporationUserRepository.DeleteUser(userCreated.UserId);
                //throw new ExectionException("Erorr trying to create user");
            }
            return(userCreated);
        }
Esempio n. 16
0
        public void UpdateUser(Corporation updatedUser, Corporation userWithId)
        {
            if (!CheckUniqueUsername(updatedUser.Username, true, userWithId.UserId))
            {
                //Unique violation
                throw new UniqueValueViolationException("Username should be unique");
            }
            City city = _cityRepository.GetCityByCityId(updatedUser.CityId);

            if (city == null)
            {
                throw new ForeignKeyConstraintViolationException("Foreign key constraint violated");
            }
            updatedUser.RoleId = userWithId.RoleId;
            updatedUser.Email  = userWithId.Email;
            updatedUser.Role   = _roleRepository.GetRoleByRoleId(userWithId.RoleId);
            updatedUser.City   = city;
            updatedUser.UserId = userWithId.UserId;
            _mapper.Map(updatedUser, userWithId);
            _corporationUserRepository.SaveChanges();

            //Updating identity table
            AccountInfo acc      = _userManager.FindByIdAsync(userWithId.UserId.ToString()).Result;
            string      username = string.Join("", updatedUser.Username.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));

            acc.UserName = username;
            _userManager.UpdateAsync(acc).Wait();
        }
Esempio n. 17
0
        public void PostRecordReturnsOkWhenModelIsValid()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);
            _mapperMock.Setup(m => m.Map <RecordReturnModel>(It.IsAny <Record>()))
            .Returns(new RecordReturnModel());
            _mapperMock.Setup(m => m.Map <Record>(It.IsAny <RecordModel>()))
            .Returns(new Record());
            var result = _sut.PostEntity(validModel) as OkObjectResult;

            Assert.That(result, Is.Not.Null);
            Assert.That((RecordReturnModel)result.Value, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Add(It.IsAny <Record>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
        public void InsuranceBuy(Character character, IEnumerable <long> robotEids)
        {
            //auto clean
            InsuranceHelper.CleanUpInsurances();

            var currentInsurances = InsuranceHelper.CountInsurances(character);
            var maxInsurances     = RealMaxSlotsPerCharacter(character);
            var insuranceDays     = GetInsuranceDays(character);

            Corporation usedCorporation = null;

            foreach (var robot in robotEids.Select(RobotHelper.LoadRobotOrThrow))
            {
                try
                {
                    InsuranceBuy(character, robot, ref currentInsurances, maxInsurances, insuranceDays, ref usedCorporation);
                }
                catch (PerpetuumException gex)
                {
                    character.SendItemErrorMessage(Commands.ProductionInsuranceBuy, gex.error, robot);
                }
            }

            usedCorporation?.SendInsuranceList();
        }
Esempio n. 19
0
    public Ship CreateShip(int hangarID)
    {
        if (!_container._hangars.ContainsKey(hangarID))
        {
            return(null);
        }

        Hangar      h     = _container._hangars[hangarID];
        Corporation c     = _container._corps[h.Corp];
        Character   owner = _container._characters[c.Owner];


        if (c.ICU < 50)
        {
            return(null);
        }

        Ship ship = new Ship(_container._shipIDs++);

        ship.Loaded = true;
        ship.Name   = "Battlestar " + ship.ID;
        ship.Corp   = h.Corp;
        ship.Status = "Idle";
        ship.Hangar = h.ID;

        _container._ships.Add(ship.ID, ship);

        h.Ships.Add(ship.ID);

        c.ICU -= 50;

        return(ship);
    }
Esempio n. 20
0
        protected override BoundService CreateBoundInstance(PyDataType objectData, CallInformation call)
        {
            if (objectData is PyInteger == false)
            {
                throw new CustomError("Cannot bind reprocessingSvc service to unknown object");
            }

            PyInteger stationID = objectData as PyInteger;

            if (this.MachoResolveObject(stationID, 0, call) != this.BoundServiceManager.Container.NodeID)
            {
                throw new CustomError("Trying to bind an object that does not belong to us!");
            }

            Station station = this.ItemFactory.GetStaticStation(stationID);

            // check if the station has the required services
            if (station.HasService(StaticData.Inventory.Station.Service.ReprocessingPlant) == false)
            {
                throw new CustomError("This station does not allow for reprocessing plant services");
            }
            // ensure the player is in this station
            if (station.ID != call.Client.StationID)
            {
                throw new CanOnlyDoInStations();
            }

            Corporation   corporation = this.ItemFactory.GetItem <Corporation>(station.OwnerID);
            ItemInventory inventory   = this.ItemFactory.MetaInventoryManager.RegisterMetaInventoryForOwnerID(station, call.Client.EnsureCharacterIsSelected());

            return(new reprocessingSvc(this.ReprocessingDB, this.StandingDB, corporation, station, inventory, this.ItemFactory, this.BoundServiceManager, call.Client));
        }
Esempio n. 21
0
        private void InitializeTypeParameters(IHasTypeParameters itemAsT, SyntaxNode node, IDom parent, SemanticModel model)
        {
            if (itemAsT == null)
            {
                return;
            }

            //var symbol = ((IRoslynHasSymbol)itemAsT).Symbol as INamedTypeSymbol;
            //var interfaces = symbol.Interfaces;
            var typeParameterList = node.ChildNodes().OfType <TypeParameterListSyntax>().SingleOrDefault();

            if (typeParameterList == null)
            {
                return;
            }

            var typeParameters = typeParameterList.Parameters;

            foreach (var p in typeParameters)
            {
                var newBase = Corporation.Create(p, itemAsT, model).Single()
                              as ITypeParameter;
                itemAsT.TypeParameters.AddOrMove(newBase);
            }
        }
Esempio n. 22
0
    private IEnumerator CreateCorpRequest(Request r)
    {
        yield return(new WaitForSeconds(_loadTime));

        CreateCorpRequest c = r as CreateCorpRequest;

        Corporation c1 = new Corporation(_container._corps.Count + 1);

        c1.Loaded      = true;
        c1.Name        = c.Name;
        c1.Owner       = c.Char;
        c1.Station     = c.Station;
        c1.ICU         = 1000;
        c1.FlightPlans = new List <int>();

        _container._corps.Add(c1.ID, c1);
        _container._characters[c.Char].Corp = c1.ID;

        Hangar h = CreateHangar(c.Station, c1.ID);
        Ship   s = CreateShip(h.ID);

        c.Corporation = c1;
        c.Character   = _container._characters[c.Char];
        c.Hangar      = h;
        c.Ship        = s;


        FinishRequest(r);
    }
Esempio n. 23
0
        public void UpdateRecordReturnsBadRequestWhenIdFromModelDoesNotMatchIdFromQueryParameter()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.UpdateEntity(validModel, validModel.Id + 1) as BadRequestObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Esempio n. 24
0
        public void UpdateRecordReturnsOkWhenEverythingIsCorrect()
        {
            var validModel = new RecordModel
            {
                Id               = 1,
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _recordRepositoryMock.Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()))
            .Returns(true);
            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.UpdateEntity(validModel, validModel.Id) as OkResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Once);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Esempio n. 25
0
 private Corporation[] LoadCorporationsFromDb()
 {
     return(Db.Query().CommandText("select corporationEID from alliancemembers where allianceEID=@allianceEID")
            .SetParameter("@allianceEID", Eid)
            .Execute()
            .Select(r => Corporation.GetOrThrow(r.GetValue <long>(0))).ToArray());
 }
Esempio n. 26
0
        public void UpdateRecordReturnsBadRequestWhenModelIsInvalid()
        {
            var invalidModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var fuelCard       = new FuelCard();
            var corporation    = new Corporation();
            var costAllocation = new CostAllocation();

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            _sut.ModelState.AddModelError("name", "name is required");

            var result = _sut.UpdateEntity(invalidModel, 1) as BadRequestResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Once);
        }
Esempio n. 27
0
        public void PostRecordReturnsNotFoundWhenCostAllocationIsNotFound()
        {
            var validModel = new RecordModel
            {
                FuelCardId       = 1,
                CorporationId    = 1,
                CostAllocationId = 1
            };

            var            fuelCard       = new FuelCard();
            var            corporation    = new Corporation();
            CostAllocation costAllocation = null;

            _fuelCardRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(fuelCard);
            _corporationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(corporation);
            _costAllocationRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(costAllocation);

            var result = _sut.PostEntity(validModel) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _recordRepositoryMock.Verify(m => m.Add(It.IsAny <Record>()), Times.Never);
            _fuelCardRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _corporationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _costAllocationRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
            _recordRepositoryMock.Verify(m => m.Find(It.IsAny <Expression <Func <Record, bool> > >()), Times.Never);
        }
Esempio n. 28
0
        public void StandingTest1()
        {
            Universe        universe = new Universe(0);
            Station         s        = universe.GetStation(1);
            Corporation     corp     = universe.CreateCorp(1);
            Ship            ship     = s.CreateShip(corp);
            ShipDestination dest     = ship.AddDestination(s);

            dest.AddLoad(ResourceElement.ResourceType.Wastes, 1000);
            ship.Start();

            Hangar corpHangar = s.CreateHangar(corp);

            ResourceElement elem  = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 2000, 1);
            ResourceStack   stack = new ResourceStack(elem);

            corpHangar.Add(stack);

            Assert.IsTrue(s.Type == Station.StationType.City);
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Water, 1) - Station.defaultStanding) < 0.0001);
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - Station.defaultStanding) < 0.0001);

            //simuler une augmentation de standing
            for (int i = 0; i < 10; i++)
            {
                universe.Update();
            }

            //apres 2 jours de chargement...
            // day1 : 0.0 + (1 * 0.05) = 0.05
            // day2 : 0.05 + ((1-0.05) * 0.05) = 0.0975
            Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - 0.0975) < 0.0001);
        }
Esempio n. 29
0
 private void OnCorpChange(Corporation c)
 {
     if (null != _corp && c.ID == _corp.ID)
     {
         UpdateVisu();
     }
 }
        public void PayOut(InsuranceDescription insurance, int definition)
        {
            if (!insurance.IsInsured)
            {
                return;
            }

            var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.InsurancePayOut)
                    .SetCreditChange(insurance.payOutPrice)
                    .SetCharacter(insurance.character)
                    .SetItem(definition, 0);

            IWallet <double> wallet;

            if (insurance.corporationEid != null)
            {
                var corporation = Corporation.GetOrThrow((long)insurance.corporationEid);
                wallet          = new CorporationWallet(corporation);
                wallet.Balance += insurance.payOutPrice;
                b.SetCreditBalance(wallet.Balance).SetCorporation(corporation);
                corporation.LogTransaction(b);
                Logger.Info($"insurance paid to corp:{insurance.corporationEid} amount:{insurance.payOutPrice}");
            }
            else
            {
                wallet          = insurance.character.GetWallet(TransactionType.InsurancePayOut);
                wallet.Balance += insurance.payOutPrice;
                b.SetCreditBalance(wallet.Balance);
                insurance.character.LogTransaction(b);
                Logger.Info($"insurance paid to character:{insurance.character.Id} amount:{insurance.payOutPrice}");
            }

            _centralBank.SubAmount(insurance.payOutPrice, TransactionType.InsurancePayOut);
        }
Esempio n. 31
0
    void CreateCorporations()
    {
        Color[] testCorpColors = new Color[5]{Color.red, Color.magenta, Color.green, Color.yellow, Color.white};
        Texture textCorpLogo = Resources.Load("Iorex Logo") as Texture;
        string testCorpDesc = "This is the description for the test corporation";

        testCorp = new Corporation("Test Corp", testCorpDesc, "Very Easy", textCorpLogo, testCorpColors);
    }
Esempio n. 32
0
    public void hilaryGoldman(bool val)
    {
                    Corporation goldman = new Corporation(3000000, 700000, "Finance", "Goldman Sachs");

        if (val)
        {
            corporationsowned.Add(goldman);

        }
        else
        {
            corporationstobuy.Add(goldman);
        }

    }
Esempio n. 33
0
    public void onClickAdd(Corporation curcorp)
    {
        dialoguecanvas = popup.GetComponent<PopupScript>().dialoguecanvas;
        dialoguepanel = popup.GetComponent<PopupScript>().dialoguepanel;


        if (popup.GetComponent<PopupScript>().getTotalMoney() < curcorp.costtobuy)
        {
            dialoguecanvas.SetActive(true);
            dialoguepanel.GetComponent<RectTransform>().anchoredPosition = new Vector2(0.0F, 0.0F);
            dialoguepanel.GetComponent<DisplayDialogScript>().title.text = "Too Little Money";
            dialoguepanel.GetComponent<DisplayDialogScript>().message.text = "Yo, You Broke Son.";
            dialoguepanel.GetComponent<DisplayDialogScript>().falsebutton.gameObject.SetActive(false);
            dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.GetComponentInChildren<Text>().text = "Continue";
            dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.onClick.AddListener(delegate { dialoguecanvas.SetActive(false); });
        }
       
        else
        {
            if (corppanel.GetComponent<CorpScript>().corporationsowned.Count >= 5)
            {
                dialoguecanvas.SetActive(true);
                dialoguepanel.GetComponent<RectTransform>().anchoredPosition = new Vector2(0.0F, 0.0F);
                dialoguepanel.GetComponent<DisplayDialogScript>().title.text = "Too Many Corporations";
                dialoguepanel.GetComponent<DisplayDialogScript>().message.text = "Maximum of Five Corprations. You're trying to run a Campaign, not a Conglomerate.";
                dialoguepanel.GetComponent<DisplayDialogScript>().falsebutton.gameObject.SetActive(false);
                dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.GetComponentInChildren<Text>().text = "Continue";
                dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.onClick.AddListener(delegate { dialoguecanvas.SetActive(false); });

            }
            else
            {
                corppanel.GetComponent<CorpScript>().AddCorporation(curcorp);
                self.interactable = false;

            }

        }
        Debug.Log("CLICKY Add");
    }
Esempio n. 34
0
 public void AddCorporation(Corporation curcorp)
 {
     corporationstobuy.Remove(curcorp);
     GameObject[] corpbuts = GameObject.FindGameObjectsWithTag("CorpBut");
     for (int j = 0; j < corpbuts.Length; j++)
     {
         if (corpbuts[j].GetComponent<AddCorpScript>().curcorp == curcorp)
             Destroy(corpbuts[j].transform.parent.gameObject);
     }
     popupregion.GetComponent<PopupScript>().IncreaseMoney(-curcorp.costtobuy);
     corporationsowned.Add(curcorp);
     makeRows();
 }
Esempio n. 35
0
        public static void CreateTestTreeInDB(ApplicationDbContext db, Corporation corp)
        {
            var node1 = new ResearchNode
            {
                Name = "Basic Rocketry",
                Description = "The basics.",
                RDCost = 10,
                CashCost = 50000,
                Script = "Action=LearnResearch:Basic Rocketry;Unlocks=Intermediate Rocketry;"
            };

            var node2 = new ResearchNode
            {
                Name = "Intermediate Rocketry",
                Description = "Werner von Braun would be delighted.",
                RDCost = 30,
                CashCost = 400000,
                Script = "Action=LearnResearch:Intermediate Rocketry;Prereq=Basic Rocketry;Unlocks=Advanced Rocketry"
            };

            var node3 = new ResearchNode
            {
                Name = "Advanced Rocketry",
                Description = "Einstein ain't got shit on these badass rockets.",
                RDCost = 75,
                CashCost = 4000000,
                Script = "Action=LearnResearch:Advanced Rocketry;Prereq=Intermediate Rocketry&Basic Rocketry;"
            };

            var learnedNode1 = new LearnedResearchNode()
            {
                Corporation = corp,
                ResearchNode = node1
            };

            db.Add(node1);
            db.Add(node2);
            db.Add(node3);
            db.Add(learnedNode1);
            db.SaveChanges();
        }
Esempio n. 36
0
 internal Character(long id, string name, Corporation corporation)
 {
     this.Id = id;
     this.Name = name;
     this.Corporation = corporation;
 }