public void Handle(ChangeChannelCommand changeChannelCommand) { telivsion = _repository.Find(changeChannelCommand.Id); telivsion.ChangeChannel(changeChannelCommand.ChannelNumber); _repository.Save(telivsion); _broker.Publish(telivsion); telivsion.EntityState.AcceptChanges(); }
public void WhenIChangeChannelAndTvIsOnThenChannelChanges() { //Arrange Television tv = new Television(); tv.TurnOn(); //Act tv.ChangeChannel(5); //Assert Assert.AreEqual(5, tv.CurrentChannel); }
public void WhenIChannelUpFrom18ItShouldBe3() { //Arrange Television tv = new Television(); tv.TurnOn(); tv.ChangeChannel(18); //Act tv.ChannelUp(); //Assert Assert.AreEqual(3, tv.CurrentChannel); }
public void SetChannelAbove18() { // Arrange Television tv = new Television(); tv.TurnOn(); int currentChannel = tv.CurrentChannel; // Act tv.ChangeChannel(19); // Assert Assert.AreEqual(currentChannel, tv.CurrentChannel); }
public void ChangingChannelToNegative_ShouldLeaveChannelAsIs() { // Arrange - create a new tv and turn it on, store the current channel Television tv = new Television(); tv.TurnOn(); int oldChannel = tv.CurrentChannel; // Act - change the channel to -1 tv.ChangeChannel(-1); // Assert - make sure channel is still the original value. Assert.AreEqual(oldChannel, tv.CurrentChannel, "Changing the channel to -1 should have left the current channel alone."); }
public void WhenTVIsCreated_DefaultValuesAreSet() { // Arrange - nothing to arrange // Act - create a new television Television tv = new Television(); Television tv2 = new Television(); // Assert - make sure default values are set properly Assert.IsFalse(tv.IsOn, "The TV should be OFF when first created."); Assert.AreEqual(3, tv.CurrentChannel, "The TV should be tuned in to channel 3 when first created."); Assert.AreEqual(2, tv.CurrentVolume, "The TV volume should be set to 2 when first created."); // Change the channel on TV and make sure the channel doesn't change on tv2 tv.ChangeChannel(15); Assert.AreEqual(3, tv2.CurrentChannel, "Changing the channel on one tv should not have changed the channel on the second tv."); }
static void Main() { Television tv = new Television(); if (tv.IsOn() == false) { tv.TurnOn(); } tv.ChangeChannel(3); tv.IncreaseVolume(); tv.IncreaseVolume(); tv.IncreaseVolume(); tv.IncreaseVolume(); tv.TurnOff(); }