public EntityReceivingAddressStorageTests() { this.databaseFactory = new TestMainDatabaseFactory(); this.network = ZcoinNetworks.Instance.Regtest; this.subject = new EntityReceivingAddressStorage(this.databaseFactory, this.network); }
public EntityRuleRepositoryTests() { this.dbFactory = new TestMainDatabaseFactory(); this.subject = new EntityRuleRepository(dbFactory); this.callbackRepository = new EntityCallbackRepository(dbFactory); this.watchRepository = new EntityWatchRepository(dbFactory); }
public EntityCallbackRepositoryTests() { this.defaultUrl = new Uri("http://zcoin.io"); this.dbFactory = new TestMainDatabaseFactory(); this.subject = new EntityCallbackRepository(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 BlocksStorageTests() { var builder = new ConfigurationBuilder(); builder.AddInMemoryCollection(new Dictionary <string, string>() { { "Zcoin:Network:Type", "Regtest" } }); this.config = builder.Build(); this.dbFactory = new TestMainDatabaseFactory(); this.subject = new BlocksStorage(this.config, this.dbFactory); }
public EntityReceivingAddressRepositoryTests() { this.databaseFactory = new TestMainDatabaseFactory(); this.network = ZcoinNetworks.Instance.Regtest; try { this.subject = new EntityReceivingAddressRepository(this.databaseFactory, this.network); } catch { this.databaseFactory.Dispose(); throw; } }
public EntityRuleRepositoryTests() { this.property = new PropertyId(3); this.address = new ReceivingAddress( Guid.NewGuid(), TestAddress.Regtest1, true, new Collection <ReceivingAddressReservation>()); this.reservation = new ReceivingAddressReservation(Guid.NewGuid(), address, DateTime.Now, null); this.address.Reservations.Add(this.reservation); this.callback = new Callback( Guid.NewGuid(), IPAddress.Parse("192.168.1.2"), DateTime.Now, false, new Uri("http://localhost/a")); this.rule = new Rule( this.property, this.reservation, new PropertyAmount(100), 6, TimeSpan.FromHours(1), new TokenReceivingCallback(this.callback, "timeout")); this.db = new TestMainDatabaseFactory(); try { this.callbacks = new Mock <ICallbackRepository>(); this.addresses = new Mock <IReceivingAddressRepository>(); this.callbacks .Setup(r => r.GetAsync(this.callback.Id, It.IsAny <CancellationToken>())) .ReturnsAsync(this.callback); this.addresses .Setup(r => r.GetReservationAsync(this.reservation.Id, It.IsAny <CancellationToken>())) .ReturnsAsync(this.reservation); this.subject = new EntityRuleRepository(this.db, this.callbacks.Object, this.addresses.Object); } catch { this.db.Dispose(); throw; } }
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; } }