Пример #1
0
        public void CloseValveWhenPotIsPresent(
            [Frozen] Mock <ICoffeeMaker> hardwareMock,
            ReliefValve sut)
        {
            sut.OnNext(WarmerPlateStatus.POT_NOT_EMPTY);

            hardwareMock.Verify(
                hw => hw.SetReliefValveState(ReliefValveState.CLOSED));
        }
Пример #2
0
        public void OpenValveWhenRemovingPotFromWarmerPlate(
            [Frozen] Mock <ICoffeeMaker> hardwareMock,
            ReliefValve sut)
        {
            sut.OnNext(WarmerPlateStatus.WARMER_EMPTY);

            hardwareMock.Verify(
                hw => hw.SetReliefValveState(ReliefValveState.OPEN));
        }
Пример #3
0
 public void OnErrorDoesNotThrowNotImplementedException(
     ReliefValve sut,
     Exception e)
 {
     try
     {
         sut.OnError(e);
     }
     catch (NotImplementedException)
     {
         Assert.True(false, "NotImplementedException thrown.");
     }
 }
Пример #4
0
        static void Main(string[] args)
        {
            var hardware = new CoffeMakerInMemory();

            hardware.SetReliefValveState(ReliefValveState.CLOSED);
            hardware.WarmerPlateStatus = WarmerPlateStatus.POT_EMPTY;

            var buttonEvents = Observable
                               .Interval(TimeSpan.FromSeconds(1))
                               .Select(_ => hardware.GetBrewButtonStatus())
                               .Publish();
            var boilerEvents = Observable
                               .Interval(TimeSpan.FromSeconds(1))
                               .Select(_ => hardware.GetBoilerStatus())
                               .Publish();
            var warmerEvents = Observable
                               .Interval(TimeSpan.FromSeconds(1))
                               .Select(_ => hardware.GetWarmerPlateStatus())
                               .Publish();

            var boiler    = new Boiler(hardware);
            var indicator = new Indicator(hardware);
            var valve     = new ReliefValve(hardware);
            var warmer    = new WarmerPlate(hardware);

            using (buttonEvents.Subscribe(boiler))
                using (buttonEvents.Subscribe(indicator))
                    using (boilerEvents.Subscribe(boiler))
                        using (boilerEvents.Subscribe(indicator))
                            using (warmerEvents.Subscribe(valve))
                                using (warmerEvents.Subscribe(warmer))
                                {
                                    buttonEvents.Connect();
                                    boilerEvents.Connect();
                                    warmerEvents.Connect();

                                    while (!Exit(hardware))
                                    {
                                        WriteHardwareState(hardware);
                                    }
                                }
        }
Пример #5
0
 public void OnNextWarmerEmptyDoesNotThrow(ReliefValve sut)
 {
     Assert.DoesNotThrow(() => sut.OnNext(WarmerPlateStatus.WARMER_EMPTY));
 }
Пример #6
0
 public void OnCompletedDoesNotThrow(ReliefValve sut)
 {
     Assert.DoesNotThrow(() => sut.OnCompleted());
 }
Пример #7
0
 public void SutIsObserverOfWarmerPlateStatus(ReliefValve sut)
 {
     Assert.IsAssignableFrom <IObserver <WarmerPlateStatus> >(sut);
 }
 public void OnCompletedDoesNotThrow(ReliefValve sut)
 {
     sut.OnCompleted();
 }