public void OpenFileButtonShouldAlwaysBeEnabledAndBoundCorrectly() { var testSubject = _With(_AnyGames()); Assert.That(testSubject.OpenCharCommand, Command.DelegatesTo(() => Always.Enabled(), () => testSubject.SwitchCharacter())); }
public void TestReplay() { Game g = new Game(5, 2, 10); Agent a = new BloodthirstyAgent(g, 1); while (g.player.location != g.dungeon.exitNode) { a.DoTurn(); } Assert.IsFalse(g.gp.InSimulation()); g.gp.Serialize("ReplayTest"); List <GamePlay> plays = loadSavedGamePlays(new List <string>() { "ReplayTest" }); foreach (GamePlay gp in plays) { // test that this specifation is respected by each game-play: Specification S = new Always(G => G.player.HP > 0); gp.replay(S); } }
public void AlwaysEnter() { Always b = new Always(); b.SendDebugEvent += new DebugFullDelegate(b_SendDebug); b.SendOrderEvent += new OrderSourceDelegate(b_SendOrder); sbcount = 0; debugs = 0; Assert.That(b.MinSize == 100); int good = 0; int i = 0; b.GotTick(timesales[i++]); if (o.isValid) good++; o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) good++; o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) good++; o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) good++; Assert.AreEqual(4, good); Assert.AreEqual(4, debugs); }
public void test_RAlert() { int level, counter = 0; int[] turns = new int[4]; // 4 turns in which combat starts turns[0] = 1; turns[1] = 10; turns[2] = 22; turns[3] = 34; g = new Game(5, 2, 30, true); gs = new Gamestate(g); savegame = new Savegame(gs); path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game9/game9_turn"; for (int j = 0; j < turns.Length; j++) { for (int h = j; h < j + 2; h++) { data = savegame.OpenFile(h, path); Gamestate gamestate1 = new Gamestate(g, data); data = savegame.OpenFile(h + 1, path); Gamestate gamestate = new Gamestate(g, data); level = gamestate1.g.dungeon.CurrentLevel(gamestate1.g.dungeon.player.location); for (int i = (level * 4); i < (level * 4) + 3; i++) { counter = 0; foreach (Pack pack in gamestate1.g.dungeon.nodeList[i].packs) { Always always = new Always((G => G.dungeon.Shortestpath(pack.location, G.dungeon.player.location).Count() <= G.dungeon.Shortestpath(gamestate.g.dungeon.nodeList[i].packs[counter++].location, G.dungeon.player.location).Count())); Assert.True(always.test(gamestate1.g)); } } } } }
public void AlwaysEnter() { Always b = new Always(); b.AllowMultipleOrders = true; Assert.That(b.MinSize == 100); int good = 0; int i = 0; Order o = new Order(); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 0); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 1); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 3); // first trade was pre-market so we only have 3 total; Assert.That(good == 3); // no debugs were sent Assert.That(debugs == 0); }
public override void Initialize() { Name = "Gamble"; Game.Join(Agent.Creature); var voxel = new VoxelHandle(Agent.World.ChunkManager, GlobalVoxelCoordinate.FromVector3(Game.Location)); if (voxel.IsValid) { Tree = new Select( new Sequence( new GoToVoxelAct(voxel, PlanAct.PlanType.Radius, Agent) { Name = "Go to gambling site.", Radius = 3.0f }, new Wrap(Gamble)), new Wrap(Cleanup)); } else { Tree = new Always(Status.Fail); } base.Initialize(); }
public override int GetHashCode() { int hash = 1; if (conditionCase_ == ConditionOneofCase.Always) { hash ^= Always.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.EnemyTagCond) { hash ^= EnemyTagCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.StatsTagCond) { hash ^= StatsTagCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.BuffCountCond) { hash ^= BuffCountCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.RuneInChallengeCond) { hash ^= RuneInChallengeCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.TimeRemainingCond) { hash ^= TimeRemainingCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.FocusLevelCond) { hash ^= FocusLevelCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.TeamCompositionCond) { hash ^= TeamCompositionCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.TimeOfDayCond) { hash ^= TimeOfDayCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.WeatherCond) { hash ^= WeatherCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.TeamPropertyCond) { hash ^= TeamPropertyCond.GetHashCode(); } if (conditionCase_ == ConditionOneofCase.EnemiesDefeatedCond) { hash ^= EnemiesDefeatedCond.GetHashCode(); } hash ^= (int)conditionCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// make sure this box only generates orders when last one has been filled public void OneOrderAtTime() { Always b = new Always(); b.AllowMultipleOrders = false; // this is the default, but it's what we're testing b.MaxSize = Int32.MaxValue; // lets not restrict our maximum position for this example Broker broker = new Broker(); Tick t; Assert.That(b.MinSize == 100); int good = 0; int i = 0; Order o = new Order(); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 0); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 1); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); // lets change this to a limit order, so he doesn't get filled on just any tick o.price = 1; broker.sendOrder(o); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); // first trade was pre-market 2nd order was never filled so 3rd was ignored... 2 total. Assert.That(good == 2); }
public void monsterZone() { TemporalSpecification RMonster2 = new Always(G => { bool result = true; for (int i = 0; i < 20; i++) { result = result && (G.getMonster("M" + i) == null || G.getMonster("M" + i).location.zone == G.getMonster("M" + i).prevZone); } return(result); }); Assert.AreEqual(Judgement.RelevantlyValid, RMonster2.evaluate(testsuites, threshold)); }
public void test_RNode() { int monstersOnNode = 0; int l, c, m; for (int k = 1; k < 9; k++) { if (k < 5) { l = 5; } else { l = 10; } if (k % 2 == 0) { c = 3; } else { c = 2; } if (k == 3 || k == 4 || k == 7 || k == 8) { m = 50; } else { m = 30; } g = new Game(l, c, m, true); gs = new Gamestate(g); savegame = new Savegame(gs); path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn"; for (int i = 0; i < gameturns[k - 1]; i++) { data = savegame.OpenFile(i, path); Gamestate gamestate = new Gamestate(g, data); foreach (Node node in gamestate.g.dungeon.nodeList) { monstersOnNode = 0; foreach (Pack pack in node.packs) { monstersOnNode += pack.members.Count(); } Always always = new Always((G => monstersOnNode <= G.dungeon.multiplier * (G.dungeon.Level(node) + 1))); Assert.True(always.test(gamestate.g)); } } } }
public void AlwaysPredicate() { List <GamePlay> plays = loadSavedGamePlays(allReplays); foreach (GamePlay gp in plays) { // test that this specifation is respected by each game-play: Specification S = new Always(G => G.player.HP > 0); gp.replay(S); Assert.IsTrue(S.getVerdict()); } }
public void test_RZone() { int l, c, m; int counter = 0; for (int k = 1; k < 9; k++) { if (k < 5) { l = 5; } else { l = 10; } if (k % 2 == 0) { c = 3; } else { c = 2; } if (k == 3 || k == 4 || k == 7 || k == 8) { m = 50; } else { m = 30; } g = new Game(l, c, m, true); gs = new Gamestate(g); savegame = new Savegame(gs); path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn"; for (int i = 0; i < gameturns[k - 1]; i++) { counter = 0; data = savegame.OpenFile(i, path); Gamestate gamestate = new Gamestate(g, data); foreach (Pack pack in gamestate.g.dungeon.packs) { Always always = new Always((G => G.dungeon.packs[counter++].zone == G.dungeon.CurrentLevel(pack.location))); Assert.True(always.test(gamestate.g)); } } } }
private void ListBoxItem_Selected_9(object sender, RoutedEventArgs e) { StopAllMusic(); Always.Play(); BitmapImage newIm = new BitmapImage(); newIm.BeginInit(); newIm.UriSource = new Uri(@"C:\Users\admin\Desktop\VirtualOrchestra\GUI\Resources\unicorn.jpg"); newIm.EndInit(); PreviewImage.Source = newIm; ArtistName.Content = "Erasure"; SongName.Content = "Always"; YearText.Content = "1994"; songFile = @"C:\Users\admin\Desktop\VirtualOrchestra\Sample MIDIs\always.mid"; songName = "Erasure: Always"; }
public void MaxSizeTest() { Always b = new Always(); b.MinSize = 100; b.MaxSize = 200; Position p = new Position(s); Order o = new Order(); Assert.That(b.MinSize == 100); Assert.That(b.MaxSize == 200); for (int i = 0; i < timesales.Length; i++) { Tick t = new Tick(timesales[i]); if (o.isValid && t.isTrade) { o.Fill(t); p.Adjust((Trade)o); o = new Order(); } Assert.That(p.Size <= b.MaxSize); o = b.Trade(timesales[i], new BarList(), p, new BoxInfo()); } Assert.That(p.Size == 200); // Now we'll set maxsize to 100 b = new Always(); b.MinSize = 100; b.MaxSize = 100; p = new Position(s); o = new Order(); Assert.That(b.MinSize == 100); Assert.That(b.MaxSize == 100); for (int i = 0; i < timesales.Length; i++) { Tick t = new Tick(timesales[i]); if (o.isValid && t.isTrade) { o.Fill(t); p.Adjust((Trade)o); o = new Order(); } Assert.That(p.Size <= b.MaxSize); o = b.Trade(timesales[i], new BarList(), p, new BoxInfo()); } Assert.That(p.Size == 100); }
public void NewsTest() { // subscribe to news service that will count everytime a debug is sent Always b = new Always(); // send debugs from reponse to our news service b.SendDebugEvent += new DebugDelegate(b_SendDebug); b.SendOrderEvent += new OrderSourceDelegate(b_SendOrder); int good = 0; debugs = 0; for (int i = 0; i < timesales.Length; i++) { o = new OrderImpl(); b.GotTick(timesales[i]); if (o.isValid) good++; } Assert.AreEqual(4, good); // news from the box was received. Assert.That(debugs>0); }
public void AlwaysEnter() { Always b = new Always(); b.AllowMultipleOrders = true; Assert.That(b.MinSize == 100); int good = 0; int i = 0; Order o = new Order(); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 0); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 1); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo()); if (o.isValid) { good++; } Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 3); // first trade was pre-market so we only have 3 total; Assert.That(good == 3); // no debugs were sent Assert.That(debugs == 0); }
public void AlwaysEnter() { Always b = new Always(); b.SendDebug += new DebugFullDelegate(b_SendDebug); b.SendOrder += new OrderDelegate(b_SendOrder); sbcount = 0; debugs = 0; Assert.That(b.MinSize == 100); int good = 0; int i = 0; b.GotTick(timesales[i++]); if (o.isValid) { good++; } o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) { good++; } o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) { good++; } o = new OrderImpl(); b.GotTick(timesales[i++]); if (o.isValid) { good++; } Assert.AreEqual(4, good); Assert.AreEqual(4, debugs); }
public void TestBuildPolicy() { var always = new Always(); always.AddJid("*****@*****.**"); always.AddJid("*****@*****.**"); var never = new Never(); never.AddJid("*****@*****.**"); never.AddJid("*****@*****.**"); never.AddJid("*****@*****.**"); var prefs = new Preferences() { Default = DefaultPreference.Roster, Never = never, Always = always }; prefs.ShouldBe(PREFS6); }
public void NewsTest() { // subscribe to news service that will count everytime a debug is sent Always b = new Always(); // send debugs from reponse to our news service b.SendDebug += new DebugFullDelegate(b_SendDebug); b.SendOrder += new OrderDelegate(b_SendOrder); int good = 0; debugs = 0; for (int i = 0; i < timesales.Length; i++) { o = new OrderImpl(); b.GotTick(timesales[i]); if (o.isValid) { good++; } } Assert.AreEqual(4, good); // news from the box was received. Assert.That(debugs > 0); }
public void NewsTest() { // subscribe to news service that will count everytime a debug is sent Always b = new Always(); // send debugs from this box to our news service b.GotDebug += new DebugFullDelegate(b_GotDebug); b.AllowMultipleOrders = true; // lets allow multiple orders for more debugging // this time we want to throw news events for debugging statements b.Debug = true; int good = 0; b.D("Starting debug test for NUnit..."); for (int i = 0; i < timesales.Length; i++) { if (b.Trade(timesales[i], new BarList(), new Position(s), new BoxInfo()).isValid) { good++; } } b.D("NUnit testing complete..."); Assert.That(good == 3); // news from the box was received. Assert.That(debugs > 0); }
public void MaxSizeTest() { Always b = new Always(); b.MinSize = 100; b.MaxSize = 200; Position p = new Position(s); Order o = new Order(); Assert.That(b.MinSize==100); Assert.That(b.MaxSize==200); for (int i = 0; i < timesales.Length; i++) { Tick t = new Tick(timesales[i]); if (o.isValid && t.isTrade) { o.Fill(t); p.Adjust((Trade)o); o = new Order(); } Assert.That(p.Size<=b.MaxSize); o = b.Trade(timesales[i], new BarList(), p, new BoxInfo()); } Assert.That(p.Size == 200); // Now we'll set maxsize to 100 b = new Always(); b.MinSize = 100; b.MaxSize = 100; p = new Position(s); o = new Order(); Assert.That(b.MinSize == 100); Assert.That(b.MaxSize == 100); for (int i = 0; i < timesales.Length; i++) { Tick t = new Tick(timesales[i]); if (o.isValid && t.isTrade) { o.Fill(t); p.Adjust((Trade)o); o = new Order(); } Assert.That(p.Size <= b.MaxSize); o = b.Trade(timesales[i], new BarList(), p, new BoxInfo()); } Assert.That(p.Size == 100); }
private void StopAllMusic() { bool parAndPause = ParaAnd.CanPause; if (parAndPause == true) { ParaAnd.Stop(); } bool fallPause = Fall.CanPause; if (fallPause == true) { Fall.Stop(); } bool prayerPause = Prayer.CanPause; if (prayerPause == true) { Prayer.Stop(); } bool hardDayPause = HardDay.CanPause; if (hardDayPause == true) { HardDay.Stop(); } bool sym5Pause = Sym5.CanPause; if (sym5Pause == true) { Sym5.Stop(); } bool rockAmadeusPause = RockAmadeus.CanPause; if (rockAmadeusPause == true) { RockAmadeus.Stop(); } bool getLuckyPause = GetLucky.CanPause; if (getLuckyPause == true) { GetLucky.Stop(); } bool mtKingPause = MtKing.CanPause; if (mtKingPause == true) { MtKing.Stop(); } bool alwaysPause = Always.CanPause; if (alwaysPause == true) { Always.Stop(); } bool airGPause = AirG.CanPause; if (airGPause == true) { AirG.Stop(); } bool newWorldPause = NewWorld.CanPause; if (newWorldPause == true) { NewWorld.Stop(); } bool swanLakePause = SwanLake.CanPause; if (swanLakePause == true) { SwanLake.Stop(); } bool bohemianPause = Bohemian.CanPause; if (bohemianPause == true) { Bohemian.Stop(); } bool dovesPause = Doves.CanPause; if (dovesPause == true) { Doves.Stop(); } bool canHeatPause = CanHeat.CanPause; if (canHeatPause == true) { CanHeat.Stop(); } bool flashPause = Flash.CanPause; if (flashPause == true) { Flash.Stop(); } bool heyYaPause = HeyYa.CanPause; if (heyYaPause == true) { HeyYa.Stop(); } bool lifePause = Life.CanPause; if (lifePause == true) { Life.Stop(); } bool mansWorldPause = MansWorld.CanPause; if (mansWorldPause == true) { MansWorld.Stop(); } bool stairwayPause = Stairway.CanPause; if (stairwayPause == true) { Stairway.Stop(); } bool superstitionPause = Superstition.CanPause; if (superstitionPause == true) { Superstition.Stop(); } }
private void AlwaysLoop(object sender, RoutedEventArgs e) { Always.Position = TimeSpan.Zero; Always.Play(); }
private void addClauseButton_Click(object sender, EventArgs e) { Actor epsilonActor = new Actor("ϵ"); switch (currentClause) { case 0: { Initially stmt = ((InitiallyClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { clausesListBox.Items.Add(stmt); _domain.AddInitiallyClause(stmt); } break; } case 1: { Causes stmt = ((CausesClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { if (stmt.Actors.Contains(epsilonActor)) { stmt = new Causes(stmt.Action, stmt.Exclusion, availableActors, stmt.Effect, stmt.Condition); } clausesListBox.Items.Add(stmt); _domain.AddCausesClause(stmt); } break; } case 2: { TypicallyCauses stmt = ((TypicallyCausesClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { if (stmt.Actors.Contains(epsilonActor)) { stmt = new TypicallyCauses(stmt.Action, stmt.Exclusion, availableActors, stmt.Effect, stmt.Condition); } clausesListBox.Items.Add(stmt); _domain.AddTypicallyCausesClause(stmt); } break; } case 3: { Releases stmt = ((ReleasesClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { if (stmt.Actors.Contains(epsilonActor)) { stmt = new Releases(stmt.Action, stmt.Exclusion, availableActors, stmt.Fluent, stmt.Condition); } clausesListBox.Items.Add(stmt); _domain.AddReleasesClause(stmt); } break; } case 4: { Preserves stmt = ((PreservesClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { if (stmt.Actors.Contains(epsilonActor)) { stmt = new Preserves(stmt.Action, stmt.Exclusion, availableActors, stmt.Fluent, stmt.Condition); } clausesListBox.Items.Add(stmt); _domain.AddPreservesClause(stmt); } break; } case 5: { Always stmt = ((AlwaysClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { clausesListBox.Items.Add(stmt); _domain.AddAlwaysClause(stmt); } break; } case 6: { Impossible stmt = ((ImpossibleClauseControl)clauseControls[currentClause]).getClause(); if (stmt != null) { if (stmt.Actors.Contains(epsilonActor)) { stmt = new Impossible(stmt.Action, stmt.Exclusion, availableActors, stmt.Condition); } clausesListBox.Items.Add(stmt); _domain.AddImpossibleClause(stmt); } break; } } }
private SyncTestContext CreateSyncManager(int index) { NoErrorLimboLogs logManager = NoErrorLimboLogs.Instance; ConsoleAsyncLogger logger = new(LogLevel.Debug, "PEER " + index + " "); // var logManager = new OneLoggerLogManager(logger); SingleReleaseSpecProvider specProvider = new(ConstantinopleFix.Instance, MainnetSpecProvider.Instance.ChainId); IDbProvider dbProvider = TestMemDbProvider.Init(); IDb blockDb = dbProvider.BlocksDb; IDb headerDb = dbProvider.HeadersDb; IDb blockInfoDb = dbProvider.BlockInfosDb; IDb codeDb = dbProvider.CodeDb; IDb stateDb = dbProvider.StateDb; TrieStore trieStore = new(stateDb, LimboLogs.Instance); StateReader stateReader = new(trieStore, codeDb, logManager); StateProvider stateProvider = new(trieStore, codeDb, logManager); stateProvider.CreateAccount(TestItem.AddressA, 10000.Ether()); stateProvider.Commit(specProvider.GenesisSpec); stateProvider.CommitTree(0); stateProvider.RecalculateStateRoot(); StorageProvider storageProvider = new(trieStore, stateProvider, logManager); InMemoryReceiptStorage receiptStorage = new(); EthereumEcdsa ecdsa = new(specProvider.ChainId, logManager); BlockTree tree = new(blockDb, headerDb, blockInfoDb, new ChainLevelInfoRepository(blockInfoDb), specProvider, NullBloomStorage.Instance, logManager); ITransactionComparerProvider transactionComparerProvider = new TransactionComparerProvider(specProvider, tree); TxPool.TxPool txPool = new(new InMemoryTxStorage(), ecdsa, new ChainHeadInfoProvider(specProvider, tree, stateReader), new TxPoolConfig(), new TxValidator(specProvider.ChainId), logManager, transactionComparerProvider.GetDefaultComparer()); BlockhashProvider blockhashProvider = new(tree, LimboLogs.Instance); VirtualMachine virtualMachine = new(stateProvider, storageProvider, blockhashProvider, specProvider, logManager); Always sealValidator = Always.Valid; HeaderValidator headerValidator = new(tree, sealValidator, specProvider, logManager); Always txValidator = Always.Valid; OmmersValidator ommersValidator = new(tree, headerValidator, logManager); BlockValidator blockValidator = new(txValidator, headerValidator, ommersValidator, specProvider, logManager); ISyncConfig syncConfig = _synchronizerType == SynchronizerType.Fast ? SyncConfig.WithFastSync : SyncConfig.WithFullSyncOnly; RewardCalculator rewardCalculator = new(specProvider); TransactionProcessor txProcessor = new(specProvider, stateProvider, storageProvider, virtualMachine, logManager); BlockProcessor blockProcessor = new( specProvider, blockValidator, rewardCalculator, txProcessor, stateProvider, storageProvider, txPool, receiptStorage, NullWitnessCollector.Instance, logManager); RecoverSignatures step = new(ecdsa, txPool, specProvider, logManager); BlockchainProcessor processor = new(tree, blockProcessor, step, logManager, BlockchainProcessor.Options.Default); ITimerFactory timerFactory = Substitute.For <ITimerFactory>(); NodeStatsManager nodeStatsManager = new(timerFactory, logManager); SyncPeerPool syncPeerPool = new(tree, nodeStatsManager, 25, logManager); StateProvider devState = new(trieStore, codeDb, logManager); StorageProvider devStorage = new(trieStore, devState, logManager); VirtualMachine devEvm = new(devState, devStorage, blockhashProvider, specProvider, logManager); TransactionProcessor devTxProcessor = new(specProvider, devState, devStorage, devEvm, logManager); BlockProcessor devBlockProcessor = new( specProvider, blockValidator, rewardCalculator, devTxProcessor, devState, devStorage, txPool, receiptStorage, NullWitnessCollector.Instance, logManager); BlockchainProcessor devChainProcessor = new(tree, devBlockProcessor, step, logManager, BlockchainProcessor.Options.NoReceipts); ITxFilterPipeline txFilterPipeline = TxFilterPipelineBuilder.CreateStandardFilteringPipeline(LimboLogs.Instance, specProvider); TxPoolTxSource transactionSelector = new(txPool, stateReader, specProvider, transactionComparerProvider, logManager, txFilterPipeline); DevBlockProducer producer = new( transactionSelector, devChainProcessor, stateProvider, tree, processor, new BuildBlocksRegularly(TimeSpan.FromMilliseconds(50)).IfPoolIsNotEmpty(txPool), Timestamper.Default, specProvider, new MiningConfig(), logManager); SyncProgressResolver resolver = new( tree, receiptStorage, stateDb, new MemDb(), NullTrieNodeResolver.Instance, syncConfig, logManager); MultiSyncModeSelector selector = new(resolver, syncPeerPool, syncConfig, logManager); Synchronizer synchronizer = new( dbProvider, MainnetSpecProvider.Instance, tree, NullReceiptStorage.Instance, blockValidator, sealValidator, syncPeerPool, nodeStatsManager, StaticSelector.Full, syncConfig, logManager); SyncServer syncServer = new( stateDb, codeDb, tree, receiptStorage, Always.Valid, Always.Valid, syncPeerPool, selector, syncConfig, NullWitnessCollector.Instance, logManager); ManualResetEventSlim waitEvent = new(); tree.NewHeadBlock += (_, _) => waitEvent.Set(); if (index == 0) { _genesis = Build.A.Block.Genesis.WithStateRoot(stateProvider.StateRoot).TestObject; producer.Start(); } syncPeerPool.Start(); synchronizer.Start(); processor.Start(); tree.SuggestBlock(_genesis); if (!waitEvent.Wait(1000)) { throw new Exception("No genesis"); } SyncTestContext context = new(); context.Ecdsa = ecdsa; context.BlockchainProcessor = processor; context.PeerPool = syncPeerPool; context.StateProvider = stateProvider; context.Synchronizer = synchronizer; context.SyncServer = syncServer; context.Tree = tree; context.BlockProducer = producer; context.TxPool = txPool; context.Logger = logger; return(context); }
public void NodeCap() { TemporalSpecification RNodeCap = new Always(G => HelperPredicates.forall(G.dungeon.nodes(), n => n.monsters.Count <= n.capacity)); Assert.AreEqual(Judgement.RelevantlyValid, RNodeCap.evaluate(testsuites, threshold)); }
public void Exit() { TemporalSpecification RExit = new Always(G => G.player.location.isReachable(G.dungeon.getExitnode())); Assert.AreEqual(Judgement.RelevantlyValid, RExit.evaluate(testsuites, threshold)); }
public void HPTest() { TemporalSpecification RHP = new Always(G => G.player.HP <= G.player.HPmax); Assert.AreEqual(Judgement.RelevantlyValid, RHP.evaluate(testsuites, threshold)); }
public void RegisterTick() { StartPoint = this; }
public void DeleteAlwaysClause(Always clause) { AlwaysClauses.Remove(clause); }
public void NewsTest() { // subscribe to news service that will count everytime a debug is sent Always b = new Always(); // send debugs from this box to our news service b.GotDebug += new DebugFullDelegate(b_GotDebug); b.AllowMultipleOrders = true; // lets allow multiple orders for more debugging // this time we want to throw news events for debugging statements b.Debug = true; int good = 0; b.D("Starting debug test for NUnit..."); for (int i = 0; i < timesales.Length; i++) if (b.Trade(timesales[i], new BarList(), new Position(s), new BoxInfo()).isValid) good++; b.D("NUnit testing complete..."); Assert.That(good == 3); // news from the box was received. Assert.That(debugs>0); }
public void test_REndZone() { int counter = 0; int l, c, m; bool REndZone = false; for (int k = 1; k < 9; k++) { if (k < 5) { l = 5; } else { l = 10; } if (k % 2 == 0) { c = 3; } else { c = 2; } if (k == 3 || k == 4 || k == 7 || k == 8) { m = 50; } else { m = 30; } g = new Game(l, c, m, true); gs = new Gamestate(g); savegame = new Savegame(gs); path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn"; for (int j = 0; j < gameturns[k - 1] - 1; j++) { counter = 0; data = savegame.OpenFile(j, path); Gamestate gamestate1 = new Gamestate(g, data); data = savegame.OpenFile(j + 1, path); Gamestate gamestate = new Gamestate(g, data); if (gamestate1.g.dungeon.Level(gamestate1.g.dungeon.player.location) == l) { REndZone = true; } for (int i = gamestate1.g.dungeon.nodeList.Count() - 1; i > gamestate1.g.dungeon.nodeList.Count() - 6; i--) { counter = 0; if (REndZone) { // check if packs do not move away from the player when the endzone has been reached foreach (Pack pack in gamestate1.g.dungeon.nodeList[i].packs) { Always always = new Always((G => G.dungeon.Shortestpath(pack.location, G.dungeon.player.location).Count() <= G.dungeon.Shortestpath(gamestate.g.dungeon.nodeList[i].packs[counter++].location, G.dungeon.player.location).Count())); // Console.WriteLine(gamestate1.g.dungeon.Shortestpath(pack.location, gamestate1.g.dungeon.player.location).Count()); Assert.True(always.test(gamestate1.g)); } } } } } }
public void AddAlwaysClause(Always clause) { AlwaysClauses.Add(clause); }
// make sure this box only generates orders when last one has been filled public void OneOrderAtTime() { Always b = new Always(); b.AllowMultipleOrders = false; // this is the default, but it's what we're testing b.MaxSize = Int32.MaxValue; // lets not restrict our maximum position for this example Broker broker = new Broker(); Tick t; Assert.That(b.MinSize == 100); int good = 0; int i = 0; Order o = new Order(); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 0); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 1); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); // lets change this to a limit order, so he doesn't get filled on just any tick o.price = 1; broker.sendOrder(o); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); t = new Tick(timesales[i++]); broker.Execute(t); o = b.Trade(t, new BarList(), broker.GetOpenPosition(s), new BoxInfo()); broker.sendOrder(o); if (o.isValid) good++; Assert.That(b.Turns == 0); Assert.That(b.Adjusts == 2); // first trade was pre-market 2nd order was never filled so 3rd was ignored... 2 total. Assert.That(good == 2); }