Exemple #1
0
        public async Task <ActionResult> CreateBlock()
        {
            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                var body = await reader.ReadToEndAsync();

                var block = NodeHub.MineBlock(NodeHub.Blockchain.LastHash, body);

                return(Ok(block));
            }
        }
Exemple #2
0
        public void HubsAreMockableViaDynamic()
        {
            var brokerDbContext = new Mock <BrokerDbContext>();
            var nodes           = new List <Node>();
            var nodeStatues     = new List <NodeStatus>();

            brokerDbContext.Setup(x => x.Node).ReturnsDbSet(nodes);
            brokerDbContext.Setup(x => x.NodeStatus).ReturnsDbSet(nodeStatues);

            var context = new Mock <HubCallerContext>();
            var hub     = new NodeHub(new NodeService(brokerDbContext.Object), new NodeStatusService(brokerDbContext.Object));

            hub.Context = context.Object;
            hub.OnConnectedAsync().Wait();
        }