public void SetupTests() { _lightDriver = MockRepository.GenerateMock <ILightDriverService>(); _lightDriver.Stub(x => x.SwitchOffBulb(Arg <Guid> .Is.Anything)).Return(GetBooleanTask(true)); _lightDriver.Stub(x => x.SwitchOnBulb(Arg <Guid> .Is.Anything)).Return(GetBooleanTask(true)); _testService = MockRepository.GenerateMock <IDataService>(); _repository = new StreetlightRepository(_testService , _lightDriver); }
public async Task StreetlightRepository_LoggingTemperatureBulbOnOverTemp_SwitchesOffBulb() { _lightDriver.Stub(x => x.SwitchOffBulb(_bulbId)) .Return(GetBooleanTask(true)); _testService.Stub(x => x.GetBulbState(_bulbId)) .Return(GetTask(new BulbState() { BulbCurrentState = new BulbData() { IsOn = true }, BulbInformation = new BulbModel() { MaxTemperature = 100 } })); _testService.Stub(x => x.UpdateBulbStatus(Arg <BulbState> .Is.Anything , Arg <bool> .Is.Anything , Arg <FaultCode> .Is.Anything, Arg <BulbData> .Is.Anything)) .Return(GetBooleanTask(true)); await _repository.SetBulbTemperature(_bulbId, 200); _lightDriver.AssertWasCalled(x => x.SwitchOffBulb(_bulbId)); _testService.VerifyAllExpectations(); }