public void SetMode_Throws_If_Caller_Not_User()
        {
            ThermostatContract thermostat = this.NewThermostat();

            this.mockPersistentState.Setup(s => s.GetAddress(nameof(ThermostatContract.User))).Returns(this.user);

            this.mockContractState.Setup(s => s.Message.Sender).Returns(Address.Zero);

            Assert.Throws <SmartContractAssertException>(() => thermostat.SetMode((uint)ThermostatContract.ModeType.Auto));
        }
        public void SetMode_Invalid_Does_Not_Set_Mode(uint mode)
        {
            ThermostatContract thermostat = this.NewThermostat();

            this.mockPersistentState.Setup(s => s.GetUInt32(nameof(ThermostatContract.State))).Returns((uint)ThermostatContract.StateType.InUse);

            this.mockPersistentState.Setup(s => s.GetAddress(nameof(ThermostatContract.User))).Returns(this.user);

            this.mockContractState.Setup(s => s.Message.Sender).Returns(this.user);

            Assert.Throws <SmartContractAssertException>(() => thermostat.SetMode(mode));
        }
        public void SetMode_Sets_Mode(uint mode)
        {
            ThermostatContract thermostat = this.NewThermostat();

            this.mockPersistentState.Setup(s => s.GetUInt32(nameof(ThermostatContract.State))).Returns((uint)ThermostatContract.StateType.InUse);

            this.mockPersistentState.Setup(s => s.GetAddress(nameof(ThermostatContract.User))).Returns(this.user);

            this.mockContractState.Setup(s => s.Message.Sender).Returns(this.user);

            thermostat.SetMode(mode);

            this.mockPersistentState.Verify(s => s.SetUInt32(nameof(ThermostatContract.Mode), mode));
        }