public MovementFactoryTests() { SystemTime.Freeze(Today); shipmentRepository = A.Fake<IShipmentInfoRepository>(); movementRepository = A.Fake<IMovementRepository>(); assessmentRepository = A.Fake<INotificationAssessmentRepository>(); financialGuaranteeRepository = A.Fake<IFinancialGuaranteeRepository>(); consentRepository = A.Fake<INotificationConsentRepository>(); workingDayCalculator = A.Fake<IWorkingDayCalculator>(); notificationApplicationRepository = A.Fake<INotificationApplicationRepository>(); financialGuaranteeRepository = A.Fake<IFinancialGuaranteeRepository>(); dateValidator = A.Fake<IMovementDateValidator>(); var movementNumberGenerator = new MovementNumberGenerator(new NextAvailableMovementNumberGenerator(movementRepository), movementRepository, shipmentRepository); var numberOfMovements = new NumberOfMovements(movementRepository, shipmentRepository); var movementsQuatity = new NotificationMovementsQuantity(movementRepository, shipmentRepository); var numberOfActiveLoads = new NumberOfActiveLoads(movementRepository, financialGuaranteeRepository); var consentPeriod = new ConsentPeriod(consentRepository, workingDayCalculator, notificationApplicationRepository); factory = new MovementFactory(numberOfMovements, movementsQuatity, assessmentRepository, movementNumberGenerator, numberOfActiveLoads, consentPeriod, dateValidator, financialGuaranteeRepository, A.Fake<IUserContext>()); }
public MovementFactoryTests() { SystemTime.Freeze(Today); shipmentRepository = A.Fake <IShipmentInfoRepository>(); movementRepository = A.Fake <IMovementRepository>(); assessmentRepository = A.Fake <INotificationAssessmentRepository>(); financialGuaranteeRepository = A.Fake <IFinancialGuaranteeRepository>(); consentRepository = A.Fake <INotificationConsentRepository>(); workingDayCalculator = A.Fake <IWorkingDayCalculator>(); notificationApplicationRepository = A.Fake <INotificationApplicationRepository>(); financialGuaranteeRepository = A.Fake <IFinancialGuaranteeRepository>(); movementPartialRejectionRepository = A.Fake <IMovementPartialRejectionRepository>(); dateValidator = A.Fake <IMovementDateValidator>(); var movementNumberGenerator = new MovementNumberGenerator(new NextAvailableMovementNumberGenerator(movementRepository), movementRepository, shipmentRepository); var numberOfMovements = new NumberOfMovements(movementRepository, shipmentRepository); var movementsQuatity = new NotificationMovementsQuantity(movementRepository, shipmentRepository, movementPartialRejectionRepository); var numberOfActiveLoads = new NumberOfActiveLoads(movementRepository, financialGuaranteeRepository); var consentPeriod = new ConsentPeriod(consentRepository, workingDayCalculator, notificationApplicationRepository); factory = new MovementFactory(numberOfMovements, movementsQuatity, assessmentRepository, movementNumberGenerator, numberOfActiveLoads, consentPeriod, dateValidator, financialGuaranteeRepository, A.Fake <IUserContext>()); }
public void CreateMovementFactory(MovementType movementType, Type objectTypeOfMovement) { var movementFactory = new MovementFactory(); var movement = movementFactory.Create(movementType); Assert.AreEqual(movement.GetType(), objectTypeOfMovement); }
//Load enemy based on JSON using a configuration protected void Load(Enemy enemy, EnemyConfig enemyConfiguration, Vector2 origin) { //Set enemy starting position //Enemy is randomly spawned if (enemyConfiguration.randomSpawn == 1) { enemy.Position = enemy.GetRandomSpawnPosition(enemyConfiguration.spawnInterval); } else { enemy.Position = new Vector2((float)origin.X, (float)origin.Y); } //Load enemy attributes enemy.MaxHealth = enemyConfiguration.health; enemy.FireRate = enemyConfiguration.fireRate; enemy.Velocity = enemyConfiguration.velocity; enemy.Health = enemyConfiguration.health; enemy.MovementPattern = enemyConfiguration.movementPattern; //Set movement if (enemy.MovementPattern != MovementPattern.None) { this.factory = MovementFactory.MakeFactory(enemy.MovementPattern); Movement movement = this.factory.Create(enemy.Position, new Vector2((float)enemyConfiguration.direction.X, (float)enemyConfiguration.direction.Y), (float)enemy.Velocity); enemy.Movement = movement; } }
public Transaction SaveTransaction() { var transaction = MovementFactory.GetTransaction(); Context.Transactions.Add(transaction); Context.SaveChanges(); return(transaction); }
public void GetNullFromInvalidMovementTest(char instruction) { var factory = new MovementFactory(); var movement = factory.GetMovement(instruction); movement.Should().BeNull(); }
public void GetValidMovementsTest(char instruction, Type movementType) { var factory = new MovementFactory(); var movement = factory.GetMovement(instruction); movement.Should().BeOfType(movementType); }
public void CreateMovementFactoryWithUndefinedMovementType() { var movementFactory = new MovementFactory(); Assert.Throws <ArgumentNullException>(() => { var movement = movementFactory.Create(MovementType.Unknown); }); }
public CreateMovementsHandler(MovementFactory movementFactory, MovementDetailsFactory movementDetailsFactory, INotificationApplicationRepository notificationRepository, IwsContext context, IMovementAuditRepository movementAuditRepository, IUserContext userContext) { this.movementFactory = movementFactory; this.movementDetailsFactory = movementDetailsFactory; this.context = context; this.notificationRepository = notificationRepository; this.movementAuditRepository = movementAuditRepository; this.userContext = userContext; }
public static IMovement NewMovement(bool isDeposit = true) { Console.Clear(); Console.WriteLine("--- ADD NEW MOVEMENT ---"); MovementData movementData = new(); movementData.Type = GetEnum <MovementType>("Type"); string amount = GetData("Amount"); decimal.TryParse(amount, out decimal amt); movementData.Amount = amt; movementData.IssueDate = DateTime.Now; movementData.Direction = isDeposit ? MovementDirection.Deposit : MovementDirection.Withdrawal; switch (movementData.Type) { case MovementType.Cash: movementData.Executor = GetData("Executor"); break; case MovementType.CreditCard: movementData.Issuer = GetEnum <CreditCardType>("Issuer"); movementData.CardNumber = GetData("Card number"); break; case MovementType.Transfert: if (isDeposit) { movementData.FromBank = GetData("From Bank"); } else { movementData.ToBank = GetData("To Bank"); } break; default: throw new ArgumentException("Invalid Movement type."); } // other data ... return(MovementFactory.CreateMovement(movementData)); }
public static Item Create(string type, Vector2 position) { switch (type) { case "seismic": return(new SeismicCharge(SpriteLoader.LoadSprite("sesmic_charge"), MovementFactory.Create("Stationary", 0, new List <Vector2>() { position }))); default: throw new NotImplementedException("other types of items are not supported"); } }
public override Bullet Create(Vector2 origin) { //Clone a new bullet from the original bullet Bullet bullet = bullets[0].Clone(); //Set movement this.factory = MovementFactory.MakeFactory(bullet.MovementPattern); Movement movement = this.factory.Create(origin, new Vector2(0, -1), (float)bullet.Velocity); bullet.Movement = movement; //Set position of bullet bullet.Position = origin; return(bullet); }
//Create our PlayerBullet public override Bullet Create(Vector2 origin) { //Clone new player bullet from our OG bullet Bullet bullet = bullets[0].Clone(); //Set movement this.factory = MovementFactory.MakeFactory(bullet.MovementPattern); Movement movement = this.factory.Create(bullet.Position, new Vector2(0, -1), (float)bullet.Velocity); bullet.Movement = movement; //Set position of bullet bullet.Position = origin;//new Vector2((float)origin.X, (float)origin.Y); return(bullet); }
public async Task <RoverInvoker> ExecuteMovement(string movementValue) { if (!canBeMove(movementValue)) { throw new MarsRoverException("Please check rover movement type. You can use only LRM movement.", MarsRoverExceptionCode.ExecuteMovementError); } MovementFactory movementFactory = new MovementFactory(); foreach (var c in movementValue) { MovementType movementType = (MovementType)char.ToUpper(c); var move = movementFactory.Create(movementType); move.Run(this._rover); } return(this); }
public CreatePrenotificationHandler(INotificationApplicationRepository notificationRepository, IDraftMovementRepository draftMovementRepository, IwsContext context, MovementFactory movementFactory, MovementDetailsFactory movementDetailsFactory, IFileRepository fileRepository, IMovementAuditRepository movementAuditRepository, IUserContext userContext) { this.notificationRepository = notificationRepository; this.draftMovementRepository = draftMovementRepository; this.context = context; this.movementFactory = movementFactory; this.movementDetailsFactory = movementDetailsFactory; this.fileRepository = fileRepository; this.movementAuditRepository = movementAuditRepository; this.userContext = userContext; }
static void Main(string[] args) { //Test Input: //5 5 //1 2 N //LMLMLMLMM //3 3 E //MMRMMRMRRM //Expected Output: //1 3 N //5 1 E string surf = Console.ReadLine(); //5 5 ISurface surface = SurfaceFactory.CreateSurface(surf); string rov = Console.ReadLine(); //1 2 N IRover rover = RoverFactory.CreateRover(rov, surface); string moves = Console.ReadLine(); //LMLMLMLMM List <string> movements = MovementFactory.CreateMovement(moves); foreach (var movement in movements) { rover.Move(movement); } string rov2 = Console.ReadLine(); //3 3 E IRover rover2 = RoverFactory.CreateRover(rov2, surface); string moves2 = Console.ReadLine(); //MMRMMRMRRM List <string> movements2 = MovementFactory.CreateMovement(moves2); foreach (var movement2 in movements2) { rover2.Move(movement2); } Console.WriteLine($"{rover.X} {rover.Y} {rover.Direction}"); Console.WriteLine($"{rover2.X} {rover2.Y} {rover2.Direction}"); Console.ReadLine(); }
private void buildWaveFromFile(EnemyWave newWave, String filename, ContentManager _content) { waveObj JSON = JsonConvert.DeserializeObject <waveObj>(File.ReadAllText(dirpath + filename)); //'C:\Users\elifo\Desktop\MyStuff\School Projects\487sp19_bulletgame\content\BulletGame\wave5.json'.' for (int enemyIdx = 0; enemyIdx < JSON.enemies.Count; enemyIdx++) { if (JSON.enemies[enemyIdx].type == "GruntA") { _creator = new ConcreteGruntACreator(); } else if (JSON.enemies[enemyIdx].type == "GruntB") { _creator = new ConcreteGruntBCreator(); } else if (JSON.enemies[enemyIdx].type == "MidBoss") { _creator = new ConcreteMidBossCreator(); } else if (JSON.enemies[enemyIdx].type == "FinalBoss") { _creator = new ConcreteFinalBossCreator(); } EnemyMovements moves = new EnemyMovements(); MovementFactory movementFactory = new MovementFactory(); for (int rep = 0; rep < JSON.enemies[enemyIdx].movementRepetitions; rep++) { for (int moveIdx = 0; moveIdx < JSON.enemies[enemyIdx].movements.Count; moveIdx++) { moves.addMovement(movementFactory.makeMovement(JSON.enemies[enemyIdx].movements[moveIdx].type, JSON.enemies[enemyIdx].movements[moveIdx].duration)); } } Vector2 pos = new Vector2(JSON.enemies[enemyIdx].startPos[0], JSON.enemies[enemyIdx].startPos[1]); Vector2 vel = new Vector2(JSON.enemies[enemyIdx].startVel[0], JSON.enemies[enemyIdx].startVel[1]); newWave.addEnemy(_creator.CreateEnemy(pos, vel, _content, moves)); } }
public void Update(GameTime gameTime) { GameScore score = GameScore.Instance; uint diff = score.Score - lastScore; if (diff > 1000) { lastScore = score.Score; Random rand = new Random(); Vector2 position = new Vector2(rand.Next(1, 1500), rand.Next(1, 1080)); SeismicCharge charge = new SeismicCharge(SpriteLoader.LoadSprite("sesmic_charge"), MovementFactory.Create("Stationary", 0, new List <Vector2>() { position })); ItemsManager.Instance.Add(charge); } foreach (SeismicCharge charge in this.deployedBombs) { if (charge.IsAlive) { charge.Update(gameTime); } } this.deployedBombs.RemoveAll(s => !s.IsAlive); // clean up }
public Movement GetSuccesfullMovement() { var method = PaymentMethodFactory.GetVisaPaymentMethod(token: GoodToken); return(MovementFactory.GetWithdrawMovement(method, null)); }
public Movement GetFailedMovement() { var method = PaymentMethodFactory.GetVisaPaymentMethod(token: FailedToken); return(MovementFactory.GetWithdrawMovement(method, null)); }
public Parser(IReader reader, MovementFactory factory) { _reader = reader; _factory = factory; }