public void TestShipSpawningOnMissileRegistersKill() { // Given var game = Match.GetInstance(); game.StartNewGame(); var map = game.Map; var player1 = game.GetPlayer(1); var ship = player1.Ship; var player2 = game.GetPlayer(2); var initialScore = player2.Kills; // When var missile = new Missile(2) { X = ship.X, Y = ship.Y - 3 }; map.AddEntity(missile); ship.Destroy(); for (var i = 0; i < respawnDelay; i++) { game.Update(); } var finalScore = player2.Kills; // Then Assert.IsFalse(missile.Alive, "Missile was not destroyed, must've mis-timed the collision."); Assert.IsNull(player1.Ship, "Player 1 ship was not destroyed."); Assert.IsTrue(finalScore > initialScore, "Player 2 score did not increase."); }
public void Create_WhenCreateStockFailed() { //Arrange var stockData = new StockData { Name = "Apple", Price = 2, Percentage = 3, Quantity = 200, Years = 10 }; _stockRespositoryMock.Setup(g => g.Create(stockData)).Returns(false); //Act ServiceResult <StockData> result = _stockService.Create(stockData); //Assert Assert.IsNotNull(result); Assert.IsFalse(result.Succeeded); Assert.IsNull(result.Result); Assert.IsNotNull(result.Errors); _stockRespositoryMock.Verify(g => g.Create(It.IsAny <StockData[]>()), Times.Once); _calculationServiceMock.Verify(g => g.Create(It.IsAny <Calculation[]>()), Times.Never); }
public void Task_OrleansTaskScheduler() { string testName = "Task_OrleansTaskScheduler"; var baseline = DoBaseTestRun(testName + "-Baseline", numTasks); var tasks = new List <Task>(numTasks); UnitTestSchedulingContext rootContext = new UnitTestSchedulingContext(); TaskScheduler taskScheduler = TestInternalHelper.InitializeSchedulerForTesting(rootContext); QueuedTaskSchedulerTests_Set1.TimeRun(1, baseline, testName, output, () => { for (int i = 0; i < numTasks; i++) { string context = i.ToString(); Task t = CreateTask(i, context); t.Start(taskScheduler); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); }); foreach (Task t in tasks) { Assert.IsTrue(t.IsCompleted, "Task is completed"); Assert.IsFalse(t.IsFaulted, "Task did not fault"); Assert.IsNull(t.Exception, "Task did not return an Exception"); } }
public void TestAlienBackWallCollisionEndsGame() { // Given var game = Match.GetInstance(); game.StartNewGame(); var player1 = game.GetPlayer(1); var player2 = game.GetPlayer(2); // When player1.Ship.Command = ShipCommand.MoveLeft; player2.Ship.Command = ShipCommand.MoveRight; player1.AlienManager.TestMakeAllAliensMoveForward(); player1.AlienManager.TestPreventAllAliensShoot(); player2.AlienManager.TestMakeAllAliensMoveForward(); player2.AlienManager.TestPreventAllAliensShoot(); for (var i = 0; i < 11; i++) { game.Update(); } // Then Assert.IsTrue(game.GameIsOver(), "Game did not end from aliens hitting the back wall."); Assert.IsTrue(game.GetPlayer(1).Lives <= 0, "All player 1 lives should have been lost."); Assert.IsTrue(game.GetPlayer(2).Lives <= 0, "All player 2 lives should have been lost."); Assert.IsNull(game.GetPlayer(1).Ship, "Player 1 ship should have been destroyed."); Assert.IsNull(game.GetPlayer(2).Ship, "Player 2 ship should have been destroyed."); }
public void Task_MasterTaskScheduler() { string testName = "Task_MasterTaskScheduler"; var baseline = DoBaseTestRun(testName + "-Baseline", numTasks); var tasks = new List <Task>(numTasks); var masterScheduler = GetTaskScheduler(); TaskScheduler[] schedulers = new TaskScheduler[numTasks]; for (int i = 0; i < numTasks; i++) { schedulers[i] = new TaskSchedulerWrapper(masterScheduler); } QueuedTaskSchedulerTests_Set1.TimeRun(1, baseline, testName, output, () => { for (int i = 0; i < numTasks; i++) { Task t = CreateTask(i); t.Start(schedulers[i]); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); }); foreach (Task t in tasks) { Assert.IsTrue(t.IsCompleted, "Task is completed"); Assert.IsFalse(t.IsFaulted, "Task did not fault"); Assert.IsNull(t.Exception, "Task did not return an Exception"); } }
public void TestMissileDestroyingBuildingScoresKill() { // Given var game = Match.GetInstance(); game.StartNewGame(true); var map = game.Map; var player1 = game.GetPlayer(1); var ship1 = player1.Ship; var player2 = game.GetPlayer(2); var ship2 = player2.Ship; // When ship1.Command = ShipCommand.Shoot; ship2.Command = ShipCommand.BuildAlienFactory; game.Update(); for (var i = 0; i < map.Height - 4; i++) { ship2.Command = ShipCommand.MoveLeft; game.Update(); } // Then Assert.IsNull(player2.AlienFactory, "Player 2 alien factory was not destroyed."); Assert.AreEqual(1, player1.Kills, "Player 1 did not score a building kill."); }
public void TestShipSpawningOnAlienDies() { // Given var game = Match.GetInstance(); game.StartNewGame(); var player = game.GetPlayer(1); var ship = player.Ship; var aliens = game.GetPlayer(2).AlienManager; // When var alien = aliens.TestAddAlien(ship.X, ship.Y - 3); aliens.TestMakeAllAliensMoveForward(); ship.Destroy(); for (var i = 0; i < respawnDelay; i++) { game.Update(); } // Then Assert.IsFalse(alien.Alive, "Alien was not destroyed, must've mis-timed the collision."); Assert.IsNull(player.Ship, "Ship was not destroyed."); }
public void TestShipCanDestroyOwnShields() { // Given var game = Match.GetInstance(); game.StartNewGame(true); var map = game.Map; var player = game.GetPlayer(1); var ship = player.Ship; ship.Command = ShipCommand.BuildShield; game.Update(); // When ship.Command = ShipCommand.Shoot; game.Update(); // Then Assert.IsInstanceOfType(map.GetEntity(ship.X, ship.Y - 1), typeof(Shield), "Left shield tile is missing"); Assert.IsNull(map.GetEntity(ship.X + 1, ship.Y - 1), "Center shield tile was not destroyed"); Assert.IsInstanceOfType(map.GetEntity(ship.X + 2, ship.Y - 1), typeof(Shield), "Right shield tile is missing"); }
public void TestCannotHaveTwoCopiesOfSameBuildingMissileController() { // Given var game = Match.GetInstance(); game.StartNewGame(true); var map = game.Map; var ship = game.GetPlayer(1).Ship; // When ship.Command = ShipCommand.BuildMissileController; game.Update(); var building = map.GetEntity(ship.X, ship.Y + 1); for (var i = 0; i < 4; i++) { ship.Command = ShipCommand.MoveLeft; game.Update(); } ship.Command = ShipCommand.BuildMissileController; game.Update(); var noBuilding = map.GetEntity(ship.X, ship.Y + 1); // Then Assert.IsNotNull(building, "The building was not built."); Assert.IsNull(noBuilding, "The game incorrectly allowed the player to build a second copy of the same building."); }
public void GetPrimaryKeyStringOnWrongGrainReference() { var grain = GrainClient.GrainFactory.GetGrain <ISimpleGrain>(0); var key = ((GrainReference)grain).GetPrimaryKeyString(); Assert.IsNull(key); }
public void TestAlienShieldCollisionExplosion() { // Given var game = Match.GetInstance(); game.StartNewGame(); var map = game.Map; var shields = new List <Shield> { (Shield)map.GetEntity(map.Width - 4, map.Height - 5), (Shield)map.GetEntity(map.Width - 4, map.Height - 6), (Shield)map.GetEntity(map.Width - 5, map.Height - 5), (Shield)map.GetEntity(map.Width - 5, map.Height - 6) }; // When game.GetPlayer(2).AlienManager.TestMakeAllAliensMoveForward(); game.GetPlayer(2).AlienManager.TestPreventAllAliensShoot(); for (var i = 0; i < 6; i++) { game.Update(); } // Then foreach (var shield in shields) { Assert.IsNotNull(shield, "Starting shield is missing."); var entity = map.GetEntity(shield.X, shield.Y); Assert.IsNull(entity, "Shield should have been destroyed, but wasn't."); } }
public void Task_OneSyncContext() { string testName = "Task_OneSyncContext"; var baseline = DoBaseTestRun(testName + "-Baseline", numTasks); var syncContext = new AsyncTestContext(output); SynchronizationContext.SetSynchronizationContext(syncContext); var tasks = new List <Task>(numTasks); QueuedTaskSchedulerTests_Set1.TimeRun(1, baseline, testName, output, () => { for (int i = 0; i < numTasks; i++) { Task t = CreateTask(i); t.Start(); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); }); foreach (Task t in tasks) { Assert.IsTrue(t.IsCompleted, "Task is completed"); Assert.IsFalse(t.IsFaulted, "Task did not fault"); Assert.IsNull(t.Exception, "Task did not return an Exception"); } }
public async Task RequestContext_ActivityId_CM_None_E2E() { Guid nullActivityId = Guid.Empty; IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId()); Guid result = grain.E2EActivityId().Result; Assert.AreEqual(nullActivityId, result, "E2E ActivityId should not exist"); Trace.CorrelationManager.ActivityId = nullActivityId; Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set"); result = await grain.E2EActivityId(); Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly"); RequestContext.Clear(); Trace.CorrelationManager.ActivityId = nullActivityId; Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set"); for (int i = 0; i < Environment.ProcessorCount; i++) { result = await grain.E2EActivityId(); Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly"); } RequestContext.Clear(); Trace.CorrelationManager.ActivityId = nullActivityId; Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set"); result = await grain.E2EActivityId(); Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly"); RequestContext.Clear(); }
public async Task AzureTableDataManager_ReadSingleTableEntryAsync() { var data = GenerateNewData(); var tuple = await manager.ReadSingleTableEntryAsync(data.PartitionKey, data.RowKey); Assert.IsNull(tuple); }
public void IgnoreVirtualProperties() { this._fixture.Customize(new IgnoreVirtualPropertiesCustomization()); var obj = this._fixture.Create <DummyObjectWithRecursion>(); Assert.IsNull(obj.Property2); Assert.IsNull(obj.Property3); }
public async Task Test_Reminders_ReminderNotFound() { IReminderTestGrain2 g1 = GrainClient.GrainFactory.GetGrain <IReminderTestGrain2>(Guid.NewGuid()); // request a reminder that does not exist IGrainReminder reminder = await g1.GetReminderObject("blarg"); Assert.IsNull(reminder, "reminder != null"); }
public void TestDelete() { Topic topic = TopicBuilder.New().WithName("Skate").Build(); new CreateTopic().CreateNewRegister(topic); new DeleteTopic().DeleteRegister(topic); var idGet = new GetTopic().GetRegisterById(topic.Id); Assert.IsNull(idGet); }
public void TestDeleteUser() { var user = UserBuilder.New().Build(); new CreateUser().CreateNewRegister(user); new DeleteUser().DeleteRegister(user); var idGet = new GetUser().GetRegisterById(user.Id); Assert.IsNull(idGet); }
public void OrleansHostParseDeploymentGroupArg() { var expectedSiloName = this.hostname; var expectedDeploymentId = Guid.NewGuid().ToString("D"); WindowsServerHost prog = new WindowsServerHost(); Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentGroup=" + expectedDeploymentId })); Assert.AreEqual(expectedSiloName, prog.SiloHost.Name); Assert.IsNull(prog.SiloHost.DeploymentId); }
public async Task DifferentTypeArgsProduceIndependentActivations() { var grain1 = GrainFactory.GetGrain <IDbGrain <int> >(0); await grain1.SetValue(123); var grain2 = GrainFactory.GetGrain <IDbGrain <string> >(0); var v = await grain2.GetValue(); Assert.IsNull(v); }
private void AssertNoNonBetaUpdatesToInstall(UpdateCheckResult result, bool betaUpdateMightStillBeAvailable) { Assert.IsNull(result.Exception); Assert.AreEqual(0, result.ProgramUpdatesToInstall.Count(x => !x.IsBeta)); if (!betaUpdateMightStillBeAvailable) { Assert.AreEqual(0, result.ProgramUpdatesToInstall.Count); Assert.IsFalse(result.IsUpdateAvailable); } }
public void TestGetEntityOutOfBoundsReturnsNullBottomRight() { // Given var map = new Map(5, 5); // When var result = map.GetEntity(map.Width, map.Height); // Then Assert.IsNull(result, "Result should be null. No exception should be thrown."); }
public void EmptyBlockGetSegmentTooLargeBvt() { IObjectPool <FixedSizeBuffer> pool = new MyTestPooled(); FixedSizeBuffer buffer = pool.Allocate(); ArraySegment <byte> segment; Assert.IsFalse(buffer.TryGetSegment(TestBlockSize + 1, out segment), "Should not be able to get segement that is bigger than block."); Assert.IsNull(segment.Array); Assert.AreEqual(0, segment.Offset); Assert.AreEqual(0, segment.Count); }
public void TestGetEntityOutOfBoundsReturnsNullTopLeft() { // Given var map = new Map(5, 5); // When var result = map.GetEntity(-1, -1); // Then Assert.IsNull(result, "Result should be null. No exception should be thrown."); }
public void TestDelete() { Publication publication = PublicationBuilder.New().Build(); // Produção através dos métodos new CreatePublication().CreateNewRegister(publication); new DeletePublication().DeleteRegister(publication); var idGet = new GetPublication().GetRegisterById(publication.Id); Assert.IsNull(idGet); }
public async void GetForecast_CityIsNull_Null() { //arrange var param = getForecastParam(); _cityService.Setup(x => x.GeCityByName(It.IsAny <string>())).Returns((Models.ForecastService.City)null); //act var result = await _forecastService.GetForecast(param); //assert Assert.IsNull(result); }
public void IgnoreProperties() { this._fixture.Customize(new IgnorePropertiesCustomization(new string[] { "Property1", "Property2" })); var obj = this._fixture.Create <DummyObject>(); Assert.IsNull(obj.Property1); Assert.IsNull(obj.Property2); }
public void TestBuildShieldDestroysMissilesAndBullets() { // Given var game = Match.GetInstance(); game.StartNewGame(); var map = game.Map; var player = game.GetPlayer(1); var ship = player.Ship; // When var missile = new Missile(2) { X = ship.X, Y = ship.Y - 3 }; var bullet = new Bullet(2) { X = ship.X + 2, Y = ship.Y - 3 }; map.AddEntity(missile); map.AddEntity(bullet); ship.Command = ShipCommand.BuildShield; game.Update(); // Then Assert.IsFalse(missile.Alive, "Missile was not destroyed"); Assert.IsFalse(bullet.Alive, "Bullet was not destroyed"); Assert.IsNotNull(map.GetEntity(ship.X, ship.Y - 1), "Left rear shield tile is missing"); Assert.IsNotNull(map.GetEntity(ship.X + 1, ship.Y - 1), "Center rear shield tile is missing"); Assert.IsNotNull(map.GetEntity(ship.X + 2, ship.Y - 1), "Right rear shield tile is missing"); // Missiles and bullets fly for one turn before the shields spawn, hence here instead of in front Assert.IsNull(map.GetEntity(ship.X, ship.Y - 2), "Left middle shield was not destroyed"); Assert.IsNotNull(map.GetEntity(ship.X + 1, ship.Y - 2), "Center middle shield tile is missing"); Assert.IsNull(map.GetEntity(ship.X + 2, ship.Y - 2), "Right middle shield tile was not destroyed"); Assert.IsNotNull(map.GetEntity(ship.X, ship.Y - 3), "Left front shield tile is missing"); Assert.IsNotNull(map.GetEntity(ship.X + 1, ship.Y - 3), "Center front shield tile is missing"); Assert.IsNotNull(map.GetEntity(ship.X + 2, ship.Y - 3), "Right front shield tile is missing"); }
public void OmitOnRecursion(int recursionDepth) { this._fixture.Customize(new OmitOnRecursionCustomization(recursionDepth)); var obj = this._fixture.Create <DummyObjectWithRecursion>(); if (recursionDepth == 1) { Assert.IsNull(obj.Property3); } else { Assert.IsNotNull(obj.Property3); } }
public async Task AsyncTimerTest_GrainCall() { const string testName = "AsyncTimerTest_GrainCall"; TimeSpan delay = TimeSpan.FromSeconds(5); TimeSpan wait = delay.Multiply(2); ITimerCallGrain grain = null; Exception error = null; try { grain = GrainClient.GrainFactory.GetGrain <ITimerCallGrain>(GetRandomGrainId()); await grain.StartTimer(testName, delay); await Task.Delay(wait); int tickCount = await grain.GetTickCount(); Assert.AreEqual(1, tickCount, "Should be {0} timer callback", tickCount); Exception err = await grain.GetException(); Assert.IsNull(err, "Should be no exceptions during timer callback"); } catch (Exception exc) { output.WriteLine(exc); error = exc; } try { if (grain != null) { await grain.StopTimer(testName); } } catch (Exception exc) { // Ignore output.WriteLine("Ignoring exception from StopTimer : {0}", exc); } if (error != null) { Assert.Fail("Test {0} failed with error {1}", testName, error); } }