Exemple #1
0
        public void call_state_handle_upcate_count()
        {
            var state = new Mock <AbstractProtocolState>();
            var ctx   = new ProtocolContext(null, null, state.Object);

            state.Setup(x => x.handleUpdateCountCmd(ctx, It.Is <TextCommand>(t => t.action == "update-count" && t.transfer_count == 1000))).Verifiable();


            ctx.handleUpdateCountCmd(new TextCommand {
                action = "update-count", transfer_count = 1000
            });
        }
        public void ctx_counts_are_updated_by_update_count_msg()         // because update-count is deprecated
        {
            var state = new TransmitInitState();
            var ctx   = new ProtocolContext(fac.Object, storage.Object, state);

            ctx.total_count = 1000;

            var cmd = new TextCommand
            {
                action         = "update-count",
                transfer_count = 3322,
                backuped_count = 1000,
            };

            ctx.handleUpdateCountCmd(cmd);

            Assert.AreEqual(cmd.transfer_count, ctx.total_count);
            Assert.AreEqual(cmd.backuped_count, ctx.backup_count);
            Assert.AreEqual(state, ctx.GetState());
        }