public EntityRuleRepositoryTests() { this.dbFactory = new TestMainDatabaseFactory(); this.subject = new EntityRuleRepository(dbFactory); this.callbackRepository = new EntityCallbackRepository(dbFactory); this.watchRepository = new EntityWatchRepository(dbFactory); }
public EntityRuleRepositoryTests() { var serializer = JsonSerializer.Create(); this.dbFactory = new TestMainDatabaseFactory(); this.subject = new EntityRuleRepository(dbFactory, serializer); this.callbackRepository = new EntityCallbackRepository(dbFactory, serializer); this.watchRepository = new EntityWatchRepository(dbFactory, serializer); }
public EntityWatchRepositoryTests() { var network = ZcoinNetworks.Instance.Regtest; this.block1 = Block.CreateBlock(network); this.block2 = Block.CreateBlock(network); this.tx1 = Transaction.Create(network); this.tx1.Inputs.Add(TxIn.CreateCoinbase(102)); this.tx1.Outputs.Add(Money.Coins(30), TestAddress.Regtest1); this.tx1.Outputs.Add(Money.Coins(10), TestAddress.Regtest2); this.tx2 = Transaction.Create(network); this.tx2.Inputs.Add(TxIn.CreateCoinbase(103)); this.tx2.Outputs.Add(Money.Coins(40), TestAddress.Regtest2); this.tx3 = Transaction.Create(network); this.tx3.Inputs.Add(this.tx1, 0).ScriptSig = new Script(OpcodeType.OP_0); this.tx3.Outputs.Add(Money.Cents(1), TestAddress.Regtest2); this.tx4 = Transaction.Create(network); this.tx4.Inputs.Add(this.tx1, 1).ScriptSig = new Script(OpcodeType.OP_0); this.tx4.Outputs.Add(Money.Cents(1), TestAddress.Regtest2); this.block1.AddTransaction(this.tx1); this.block2.AddTransaction(this.tx2); this.block2.AddTransaction(this.tx3); this.block2.AddTransaction(this.tx4); this.block1.UpdateMerkleRoot(); this.block2.UpdateMerkleRoot(); this.address1 = new ReceivingAddress( Guid.NewGuid(), TestAddress.Regtest1, true, new Collection <ReceivingAddressReservation>()); this.address2 = new ReceivingAddress( Guid.NewGuid(), TestAddress.Regtest2, true, new Collection <ReceivingAddressReservation>()); this.reservation1 = new ReceivingAddressReservation(Guid.NewGuid(), this.address1, DateTime.Now, null); this.reservation2 = new ReceivingAddressReservation(Guid.NewGuid(), this.address2, DateTime.Now, null); this.rule1 = new Rule( new PropertyId(3), this.reservation1, new PropertyAmount(100), 6, TimeSpan.FromHours(1), new TokenReceivingCallback( new Callback( Guid.NewGuid(), IPAddress.Parse("192.168.1.2"), DateTime.Now, false, new Uri("http://localhost/a")), "timeout")); this.rule2 = new Rule( new PropertyId(4), this.reservation2, new PropertyAmount(40), 3, TimeSpan.FromMinutes(30), null); this.watch1 = new DomainModel( this.rule1, this.block1.GetHash(), this.tx1.GetHash(), this.rule1.AddressReservation.Address.Address, new PropertyAmount(100)); this.watch2 = new DomainModel( this.rule2, this.block1.GetHash(), this.tx1.GetHash(), this.rule2.AddressReservation.Address.Address, new PropertyAmount(10)); this.watch3 = new DomainModel( this.rule2, this.block2.GetHash(), this.tx2.GetHash(), this.rule2.AddressReservation.Address.Address, new PropertyAmount(10)); this.watch4 = new DomainModel( this.rule2, this.block2.GetHash(), this.tx3.GetHash(), this.rule2.AddressReservation.Address.Address, new PropertyAmount(10)); this.watch5 = new DomainModel( this.rule2, this.block2.GetHash(), this.tx4.GetHash(), this.rule2.AddressReservation.Address.Address, new PropertyAmount(10)); this.db = new TestMainDatabaseFactory(); try { this.rules = new Mock <IRuleRepository>(); this.rules .Setup(r => r.GetAsync(this.rule1.Id, It.IsAny <CancellationToken>())) .ReturnsAsync(this.rule1); this.rules .Setup(r => r.GetAsync(this.rule2.Id, It.IsAny <CancellationToken>())) .ReturnsAsync(this.rule2); this.subject = new EntityWatchRepository(this.db, this.rules.Object); } catch { this.db.Dispose(); throw; } }