public void SetTargetTemperature_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.SetTargetTemperature(TargetTemperature - 1));
        }
        public void SetTargetTemperature_Throws_If_Caller_User_But_State_Not_InUse()
        {
            ThermostatContract thermostat = this.NewThermostat();

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

            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.SetTargetTemperature(TargetTemperature - 1));
        }
        public void SetTargetTemperature_Sets_TargetTemperature(int targetTemperature)
        {
            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.SetTargetTemperature(targetTemperature);

            this.mockPersistentState.Verify(s => s.SetInt32(nameof(ThermostatContract.TargetTemperature), targetTemperature));
        }