public async Task AddAndDeleteNewCaptain_Ok() { //Arrange var id = Guid.NewGuid(); var captain = new Captain { Id = id, Name = "Test" }; //Act await m_repository.CreateAsync(captain); //Assert var(_, captains) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); Assert.Equal(id, captains.First().Id); Assert.Equal("Test", captains.First().Name); await m_repository.DeleteAsync(captain); var(_, emptyResponse) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); Assert.Empty(emptyResponse); }
public async Task UpdateNewCaptain_Ok() { //Arrange var id = Guid.NewGuid(); var captain = new Captain { Id = id, Name = "Test", }; //Act await m_repository.CreateAsync(captain); var(_, captains) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); captain.Name = "Modified"; await m_repository.UpdateAsync(new List <Captain> { captain }); var(_, updatedResponse) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); //Assert Assert.Equal(id, captains.First().Id); Assert.Equal("Modified", captains.First().Name); await m_repository.DeleteAsync(updatedResponse.First()); }
public async void UpdateWithValidData_Ok() { //Arrange var explorersTeam = new ExplorersTeam { Id = Guid.NewGuid(), Name = "Test" }; var captain = new Captain { Id = Guid.NewGuid(), Name = "Test", ExplorersTeamId = explorersTeam.Id, Age = 40, Email = "*****@*****.**" }; m_repositoryMock.Setup(t => t.SearchAsync(It.IsAny <Pagination>(), It.IsAny <Ordering>(), It.IsAny <IFilter <Captain> >())) .ReturnsAsync(new Tuple <int, List <Captain> >(1, new List <Captain> { captain })); m_explorersTeamRepositoryMock.Setup(t => t.SearchAsync(It.IsAny <Pagination>(), It.IsAny <Ordering>(), It.IsAny <ExplorersTeamFilter>())) .ReturnsAsync(new Tuple <int, List <ExplorersTeam> >(1, new List <ExplorersTeam> { explorersTeam })); //Act await m_captainService.UpdateCaptainAsync(captain); //Assert m_repositoryMock.Verify(t => t.UpdateAsync(It.IsAny <List <Captain> >()), Times.Once); }
public async void SearchCrewMember_Ok() { //Arrange var captain = new Captain { Id = Guid.NewGuid(), Name = "Test" }; m_repositoryMock.Setup(t => t.SearchAsync(It.IsAny <Pagination>(), It.IsAny <Ordering>(), It.IsAny <IFilter <CrewMember> >())) .ReturnsAsync(new Tuple <int, List <CrewMember> >(1, new List <CrewMember> { captain })); //Act var(count, captains) = await m_captainService.SearchCrewMemberAsync(new Pagination(), new Ordering(), new CrewMemberFilter { SearchTerm = captain.Id.ToString() }); //Assert m_repositoryMock.Verify(t => t.SearchAsync(It.IsAny <Pagination>(), It.IsAny <Ordering>(), It.IsAny <CrewMemberFilter>()), Times.Once); Assert.Equal(1, count); Assert.Equal(captain, captains.First()); }
public Enemy spawn() { Enemy enemy; switch (enemyType) { case "Grunt": //set center to be top right or left of the screen enemy = new Grunt(x, y); break; case "Captain": //set center to be top right or left of the screen enemy = new Captain(x, y); break; case "Commander": //set center to be top right or left of the screen enemy = new Commander(x, y); break; case "Assassin": //set center to be top right or left of the screen enemy = new Assassin(x, y); break; case "General": //set center to center top of the screen enemy = new General(x, y); break; } enemyCount--; return(enemy); }
public async Task <IActionResult> PutCaptain(int id, Captain captain) { if (id != captain.CaptainId) { return(BadRequest()); } _context.Entry(captain).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CaptainExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private Captain EmptySquadSUT() { Captain captainEmpty = CreateSUT(); captainEmpty.Apply(new CaptainCreated(new List <ICharacter>())); return(captainEmpty); }
public async Task <IActionResult> CreateCaptain([FromBody] ExplorersViewModel captainViewModel) { try { Captain captain = new Captain { UserName = captainViewModel.UserName, Name = captainViewModel.Name, IsAvailable = true }; var res = await explorersService.CreateCaptain(captain, captainViewModel.Password); if (!res.Succeeded) { ModelState.TryAddModelError(res.Errors.FirstOrDefault().Code, res.Errors.FirstOrDefault().Description); return(new BadRequestObjectResult(ModelState)); } return(new OkObjectResult("Captain succesfully added.")); } catch (Exception exc) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <IActionResult> Edit(int id, [Bind("CaptainID,FirstName,LastName,StartDate")] Captain captain) { if (id != captain.CaptainID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(captain); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CaptainExists(captain.CaptainID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(captain)); }
public async Task UpdateCaptainAsync(Captain captain) { try { var validationError = captain.Validate(); if (validationError.Any()) { throw new ValidationException($"A validation exception was raised while trying to update a Captain : {JsonConvert.SerializeObject(validationError, Formatting.Indented)}"); } await EnsureCaptainExistAsync(captain.Id); await CheckExplorersTeamExistAsync(captain.ExplorersTeamId); await m_repository.UpdateAsync(new List <Captain> { captain }); } catch (ValidationException e) { m_logger.LogWarning(e, "A validation failed"); throw; } catch (Exception e) when(e.GetType() != typeof(ValidationException)) { m_logger.LogCritical(e, $"Unexpected Exception while trying to update a Captain with the properties : {JsonConvert.SerializeObject(captain, Formatting.Indented)}"); throw; } }
public async Task <ActionResult> Login(LoginViewModel loginModel) { if (string.IsNullOrEmpty(loginModel.UserName) || string.IsNullOrEmpty(loginModel.Password)) { return(BadRequest()); } Captain captain = await _captainRepository.LoadByUsername(loginModel.UserName); if (captain is null) { return(Unauthorized()); } if (!PasswordHasher.ValidatePassword(loginModel.Password, captain.Password)) { return(Unauthorized()); } string token = GenerateTokenString(captain); return(Ok(new { Token = token, FirstName = captain.FirstName, LastName = captain.LastName, ID = captain.Identifier, Username = captain.Username })); }
private ExplorersTeam UpdateExplorersTeam(List <Robot> robots, Captain captain) { ExplorersTeam explorersTeam = appDbContext.ExplorersTeams.Where(et => et.Captain.Id == captain.Id).FirstOrDefault(); List <Robot> robotsInDb = appDbContext.Robots.ToList(); List <Robot> planetRobots = new List <Robot>(); foreach (Robot robot in robots) { var robotToAdd = robotsInDb.Where(r => r.Id == robot.Id).FirstOrDefault(); robotToAdd.IsAvailable = false; planetRobots.Add(robotToAdd); } if (explorersTeam == null) { explorersTeam = new ExplorersTeam { Captain = captain, Robots = planetRobots }; } explorersTeam.Robots = planetRobots; return(explorersTeam); }
public async Task <ActionResult <Captain> > PostCaptain(Captain captain) { _context.Captains.Add(captain); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCaptain", new { id = captain.CaptainId }, captain)); }
static void Main(string[] args) { ClubBola clubbola; //Abstract Class// clubbola = new Pemain(); clubbola.Posisi(); Console.WriteLine(); clubbola = new Captain(); clubbola.Posisi(); Console.WriteLine(); clubbola = new Pelatih(); clubbola.Posisi(); /*IClubBola clubbola; //Abstract Class// * clubbola = new Pemain(); * clubbola.Posisi(); * Console.WriteLine(); * clubbola = new Captain(); * clubbola.Posisi(); * Console.WriteLine(); * clubbola = new Pelatih(); * clubbola.Posisi()*/ Console.ReadKey(); }
public void TestAdapter() { beans = new Dictionary <string, object>(); var fishingBoatAdapter = new FishingBoatAdapter(); beans.Add(FISHING_BEAN, fishingBoatAdapter); object adapter; beans.TryGetValue(FISHING_BEAN, out adapter); var captain = new Captain(); captain.SetRowingBoat((FishingBoatAdapter)adapter); beans.Add(ROWING_BEAN, captain); beans.TryGetValue(ROWING_BEAN, out adapter); var captain = new Captain(); captain.row(); // the captain internally calls the battleship object to move var adapter = (RowingBoat)beans.get(FISHING_BEAN); verify(adapter).row(); }
private void IfCaptainHasChangedSetLastCaptainAvaialable(string captainId, string lastCaptainId) { if (captainId != lastCaptainId && lastCaptainId != "") { Captain captainToSetAvailable = appDbContext.Captains.Where(c => c.Id == lastCaptainId.ToString()).FirstOrDefault(); captainToSetAvailable.IsAvailable = true; } }
// damage boost called by weather conditions, wall powers, and other upgrades public void WeaponDamageBoost(float damageBoostPercent) { foreach (GameObject obj in captainList) { Captain captain = obj.GetComponent <Captain>(); captain.myWeapon.DamageBoost(damageBoostPercent); // this calls the Weapon script to figure out the bonus } }
public Ship(string ShipName, int SailorsNumber, Captain captain) { this.ShipName = ShipName; this.ShipsNumber = SHIPSCount; this.SailorsNumber = SailorsNumber; this.captain = captain; base.SHIPSCount++; }
//USEFUL ?????????????? RENAME !!!!!!!!!!!!!!!!!!!! /// <summary> /// Creates a new project and go straight to it /// </summary> /// <param name="name">The name of the project</param> /// <param name="startDate">the start date</param> /// <param name="endDate">the end date</param> /// <param name="home">The home window, in order to close it</param> public void InsertProject(string name, string startDate, string endDate, Home home = null) { //USEFUL ?????????? Project brandNew = new Project(name, startDate, endDate); //Going to the project window Captain captain = new Captain(); // captain.ToProject(name, home); }//InsertProject()
private static string CheckSecondOption(string input, string text, Captain capn) { if (input == capn.Expertise) { return("B) " + text + "\n"); } return(""); }
public Ship() { this.ShipName = ""; this.ShipsNumber = SHIPSCount; this.SailorsNumber = 0; base.SHIPSCount++; this.captain = new Captain(); }
public void captain_should_sail_boat() { var mockLogger = new Mock <ILogger>(); var captain = new Captain(new FishingBoatAdaptor(mockLogger.Object)); captain.Row(); mockLogger.Verify(logger => logger.Info("Fishing boat sails")); }
public RumorMediator(RumorFootballer rumorFootballer, AggressiveFootballer agressiveFootballer, Captain captain) { _rumorFootballer = rumorFootballer; _rumorFootballer.SetMediator(this); _aggresiveFootballer = agressiveFootballer; _aggresiveFootballer.SetMediator(this); _captain = captain; _captain.SetMediator(this); }
public async Task RegisterCaptainInPlanetMicroservice(Captain captain, Shuttle shuttle) { var uri = new Uri(_config["PlanetAPIUrl"] + "crewMetaData/"); await HttpHelper.PostAsync(uri, new { CaptainIdentifier = captain.Identifier, CaptainName = captain.FirstName + " " + captain.LastName, RobotList = string.Join(",", shuttle.Robots.Select(x => x.Name)), }); }
public static void Main() { Captain captain = new Captain(); captain.ConnectDriveTrain(DriveTrain()); captain.ConnectRedStream(RedStream()); // keep program running Thread.Sleep(Timeout.Infinite); }
//Metodos public List AddCaptainCard(Card card, int PlayerId = -1) { if (PlayerId == 0 || PlayerId == 1) { if (card == captainCard) { Captain.Add(card) } } }
public bool LoadSylpha() { //test function just to load up a character Character temp_char = new Character("Sylpha"); Captain starting_class = new Captain (); temp_char.UnitClass = starting_class; roster.Add(temp_char); return true; }
public void crArmy() { General congen = gen.CreateGeneral(); Captain concap = cap.CreateCaptain(); Soldier consold = sold.CreateSoldier(); congen.makeGen(); concap.makeCap(); consold.makeSold(); }
public async Task <IActionResult> Create([Bind("CaptainID,FirstName,LastName,StartDate")] Captain captain) { if (ModelState.IsValid) { _context.Add(captain); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(captain)); }
public bool LoadSylpha() { //test function just to load up a character Character temp_char = new Character("Sylpha"); Captain starting_class = new Captain(); temp_char.UnitClass = starting_class; roster.Add(temp_char); return(true); }
public void DecideActionTest() { Submarine submarine = new Submarine(new Position(7, 7)); Captain captain = new Captain(submarine); for (int i = 0; i < 100; i++) { string action = captain.DecideAction(); ActionsManager.Execute(submarine, action); } }
public void Init() { PostNumber = 43; PostList = new Posts[PostNumber]; SortedPostList = new Posts[PostNumber]; PostList [0] = SortedPostList [0] = King.SetPost(Titles[0], 0, 100, null, null); PostList [1] = SortedPostList [1] = Mentor.SetPost(Titles[1], 0, 100, null, King); PostList [2] = SortedPostList [2] = PrimeMinister.SetPost(Titles[2], 0, 100, null, King); PostList [3] = SortedPostList [16] = Voevoda.SetPost(Titles[3], 0, 100, null, King); PostList [4] = SortedPostList [3] = Kaznachei.SetPost(Titles[4], 0, 100, null, King); PostList [5] = SortedPostList [14] = Patriarch.SetPost(Titles[5], 0, 100, null, King); PostList [6] = SortedPostList [4] = Dvoretzky.SetPost(Titles[7], 0, 100, null, PrimeMinister); PostList [7] = SortedPostList [12] = Tiun.SetPost(Titles[6], 0, 100, null, King); PostList [8] = SortedPostList [5] = Okolnichiy.SetPost(Titles[8], 0, 100, null, PrimeMinister); PostList [9] = SortedPostList [6] = Questor.SetPost(Titles[9], 0, 100, null, PrimeMinister); PostList [10] = SortedPostList [17] = Guardian.SetPost(Titles[10], 0, 100, null, PrimeMinister); PostList [11] = SortedPostList [18] = Policemen.SetPost(Titles[11], 0, 100, null, PrimeMinister); PostList [12] = SortedPostList [19] = Druzhina.SetPost(Titles[12], 0, 100, null, Voevoda); PostList [13] = SortedPostList [20] = Phantoms.SetPost(Titles[13], 0, 100, null, Voevoda); PostList [14] = SortedPostList [21] = Captain.SetPost(Titles[14], 0, 100, null, Voevoda); PostList [15] = SortedPostList [22] = Spymaster.SetPost(Titles[15], 0, 100, null, PrimeMinister); PostList [16] = SortedPostList [23] = Mystik.SetPost(Titles[16], 0, 100, null, Spymaster); PostList [17] = SortedPostList [24] = Ninja.SetPost(Titles[17], 0, 100, null, Spymaster); PostList [18] = SortedPostList [25] = Sinobi.SetPost(Titles[18], 0, 100, null, Spymaster); PostList [19] = SortedPostList [26] = Orujeinichiy.SetPost(Titles[19], 0, 100, null, PrimeMinister); PostList [20] = SortedPostList [27] = Dozorny.SetPost(Titles[20], 0, 100, null, Voevoda); PostList [21] = SortedPostList [28] = Kluchnik.SetPost(Titles[21], 0, 100, null, Dvoretzky); PostList [22] = SortedPostList [29] = Stolnik.SetPost(Titles[22], 0, 100, null, Dvoretzky); PostList [23] = SortedPostList [30] = Postelnichiy.SetPost(Titles[23], 0, 100, null, Dvoretzky); PostList [24] = SortedPostList [31] = Konuchiy.SetPost(Titles[24], 0, 100, null, Dvoretzky); PostList [25] = SortedPostList [32] = Lovchiy.SetPost(Titles[25], 0, 100, null, Dvoretzky); PostList [26] = SortedPostList [13] = Grandmeister.SetPost(Titles[26], 0, 100, null, Patriarch); PostList [27] = SortedPostList [15] = Paramedik.SetPost(Titles[27], 0, 100, null, Patriarch); PostList [28] = SortedPostList [33] = Jurodiviy.SetPost(Titles[28], 0, 100, null, Patriarch); PostList [29] = SortedPostList [34] = Skomoroh.SetPost(Titles[29], 0, 100, null, PrimeMinister); PostList [30] = SortedPostList [7] = Trademaster.SetPost(Titles[30], 0, 100, null, Kaznachei); PostList [31] = SortedPostList [8] = Buildmaster.SetPost(Titles[31], 0, 100, null, Kaznachei); PostList [32] = SortedPostList [9] = Miner.SetPost(Titles[32], 0, 100, null, Kaznachei); PostList [33] = SortedPostList [10] = Agrarian.SetPost(Titles[33], 0, 100, null, Kaznachei); PostList [34] = SortedPostList [11] = Banker.SetPost(Titles[34], 0, 100, null, Kaznachei); PostList [35] = SortedPostList [35] = Tamojnya.SetPost(Titles[35], 0, 100, null, Kaznachei); PostList [36] = SortedPostList [36] = Courier.SetPost(Titles[36], 0, 100, null, PrimeMinister); PostList [37] = SortedPostList [37] = Bodyguard.SetPost(Titles[37], 0, 100, null, Guardian); PostList [38] = SortedPostList [38] = Commander1.SetPost(Titles[38], 0, 100, null, Voevoda); PostList [39] = SortedPostList [39] = Commander2.SetPost(Titles[39], 0, 100, null, Voevoda); PostList [40] = SortedPostList [40] = Commander3.SetPost(Titles[40], 0, 100, null, Voevoda); PostList [41] = SortedPostList [41] = Commander4.SetPost(Titles[41], 0, 100, null, Voevoda); PostList [42] = SortedPostList [42] = Commander5.SetPost(Titles[42], 0, 100, null, Voevoda); SetCounsillorPosts(); }
public IActionResult CreatePlanet([FromBody] AddPlanetViewModel planetViewModel) { try { Status status = appDbContext.Statuses.Where(s => s.Id == planetViewModel.StatusId).FirstOrDefault(); Captain captain = appDbContext.Captains.Where(c => c.Id == planetViewModel.CaptainId.ToString()).FirstOrDefault(); List <Robot> robots = appDbContext.Robots.ToList(); ExplorersTeam explorersTeam = new ExplorersTeam(); var robotsOfNewPlanet = new List <Robot>(); if (captain != null) { foreach (Robot robot in planetViewModel.Robots) { var robotToAdd = robots.Where(r => r.Id == robot.Id).FirstOrDefault(); robotToAdd.IsAvailable = false; robotsOfNewPlanet.Add(robotToAdd); } captain.IsAvailable = false; explorersTeam = new ExplorersTeam { Captain = captain, Robots = robotsOfNewPlanet }; } else { explorersTeam.Captain = null; explorersTeam.Robots = null; } Planet planet = new Planet { Name = planetViewModel.Name, ImageUrl = planetViewModel.ImageUrl, Description = planetViewModel.Description, Status = status, ExplorersTeam = explorersTeam }; appDbContext.Planets.Add(planet); appDbContext.SaveChanges(); return(new OkObjectResult("Planet succesfully added.")); } catch (Exception exc) { return(StatusCode(StatusCodes.Status500InternalServerError)); }; }
void _openButton_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_selectedBlock != null) { Captain oCaptain = new Captain(); oCaptain.ToProject(_selectedBlock._block.Text); } }
private void GoToProject(object sender, System.Windows.Input.MouseEventArgs e) { Captain oCaptain = new Captain(); oCaptain.ToProject(this.Text); }
void _createButton_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_nameBox.Text == "" || _nameBox.Text == "Name of your project here") { NullInputPopUp popup = new NullInputPopUp(); } else if ( _startDatePicker.SelectedDate == null) { NullInputPopUp popup = new NullInputPopUp(); } else if (_endDatePicker.SelectedDate == null ) { NullInputPopUp popup = new NullInputPopUp(); } else if(isExistingProject(_nameBox.Text)) { AlreadyExistingProject aep = new AlreadyExistingProject(Dimensions.GetWidth()/3,Dimensions.GetHeight()/4,ControlsValues.EXISTING_PROJECT); } else { _chief.InsertProject(_nameBox.Text, _startDatePicker.Text, _endDatePicker.Text); Captain oCaptain = new Captain(); oCaptain.ToProject(_nameBox.Text); } }