public void AddBlockQuery_Should_Return_False_When_Message_From_New_Block_Is_Not_In_Db() { var db = GetDatabase(); var query = new AddBlockQueryHandler(db); var result = query.Handle(new AddBlockQuery() { NewBlock = new Core.Blockchain.Block() { BlockHash = "NEW_BLOCK", BlockHashPrevious = "BLOCK_1", Length = 2, Nonce = 1, Timestamp = 2000, Messages = new List <EncryptedMessage>() { new EncryptedMessage() { Id = "MSG3", Content = "NO IN BLOCK", Title = "test", From = "fr", To = "to", FromKey = "fk", ToKey = "tk", Nonce = 1, IV = "iv" } } }, IsLongRunning = false }); Assert.False(result); }
public void AddBlockQuery_Should_Return_True_When_Successfully_Added_Block() { var db = GetDatabase(); var query = new AddBlockQueryHandler(db); var result = query.Handle(new AddBlockQuery() { NewBlock = new Core.Blockchain.Block() { BlockHash = "NEW_BLOCK", BlockHashPrevious = "BLOCK_1", Length = 2, Nonce = 1, Timestamp = 2000, Messages = new List <EncryptedMessage>() { new EncryptedMessage() { Id = "MSG1", Content = "NO IN BLOCK", Title = "test", From = "fr", To = "to", FromKey = "fk", ToKey = "tk", Nonce = 1, IV = "iv" } } }, IsLongRunning = false }); Assert.True(result); Assert.True(db.BlockChain.Count(b => b.BlockHash == "NEW_BLOCK") == 1); Assert.True(db.BlockMessages.Count(bm => bm.StoreId == 1 && bm.BlockHash == "NEW_BLOCK") == 1); }