Esempio n. 1
0
        public void GetReadyDinner_OrderDone_ExpectDinnerAndRemovedFromList()
        {
            Dinner dinner     = new Dinner();
            Guid   dinnerGuid = Guid.NewGuid();

            var openDinnerOrders = new Dictionary <Guid, Dinner>()
            {
                { dinnerGuid, dinner }
            };
            var ordersDoneAtTime = new Dictionary <Guid, DateTime>();

            ILogger <StandControl> logger          = Mock.Of <ILogger <StandControl> >();
            Mock <IEventProducer>  eventProducer   = new Mock <IEventProducer>();
            ILocationService       locationService = new LocationService(Mock.Of <ILogger <LocationService> >(),
                                                                         new Random());

            StandControl standControl = new StandControl(logger, eventProducer.Object, openDinnerOrders, ordersDoneAtTime, locationService);

            Dinner result = standControl.GetReadyDinner(dinnerGuid.ToString());

            Assert.Equal(dinner, result);

            // It should now throw a null exception, as the dinner is removed
            Assert.Throws <ArgumentNullException>(() => standControl.GetReadyDinner(dinnerGuid.ToString()));
        }
Esempio n. 2
0
        public void GetReadyDinner_OrderMissing_ExpectArgumentNullException()
        {
            Guid dinnerGuid = Guid.NewGuid();

            var openDinnerOrders = new Dictionary <Guid, Dinner>();
            var ordersDoneAtTime = new Dictionary <Guid, DateTime>();

            ILogger <StandControl> logger          = Mock.Of <ILogger <StandControl> >();
            Mock <IEventProducer>  eventProducer   = new Mock <IEventProducer>();
            ILocationService       locationService = new LocationService(Mock.Of <ILogger <LocationService> >(),
                                                                         new Random());

            StandControl standControl = new StandControl(logger, eventProducer.Object, openDinnerOrders, ordersDoneAtTime, locationService);

            Assert.Throws <ArgumentNullException>(() => standControl.GetReadyDinner(dinnerGuid.ToString()));
        }
Esempio n. 3
0
        public void GetReadyDinner_OrderNotDone_ExpectInvalidOperationException()
        {
            Dinner dinner1     = new Dinner();
            Guid   dinner1Guid = Guid.NewGuid();

            var openDinnerOrders = new Dictionary <Guid, Dinner>()
            {
                { dinner1Guid, dinner1 }
            };
            var ordersDoneAtTime = new Dictionary <Guid, DateTime>()
            {
                { dinner1Guid, DateTime.Now.AddSeconds(60) }
            };

            ILogger <StandControl> logger          = Mock.Of <ILogger <StandControl> >();
            Mock <IEventProducer>  eventProducer   = new Mock <IEventProducer>();
            ILocationService       locationService = new LocationService(Mock.Of <ILogger <LocationService> >(),
                                                                         new Random());

            StandControl standControl = new StandControl(logger, eventProducer.Object, openDinnerOrders, ordersDoneAtTime, locationService);

            Assert.Throws <InvalidOperationException>(() => standControl.GetReadyDinner(dinner1Guid.ToString()));
        }