Esempio n. 1
0
        public void Should_return_an_unit_when_provided_a_correct_menu_item()
        {
            //arrange
            var keyPair = (TimeOfDayType.Morning, DishType.Entree);
            var dish    = new Dish("eggs", AllowedOrderType.Single);
            var dict    = new Dictionary <(TimeOfDayType, DishType), Dish> {
                { keyPair, dish }
            };

            var dishesMenuServiceFake = A.Fake <IDishesMenuService>();

            A.CallTo(() => dishesMenuServiceFake.TryAddDish(keyPair, dish)).Returns(true);

            var inputProcessorService = new InputProcessorService(dishesMenuServiceFake);
            var exception             = default(ArgumentException);
            var unit = default(Unit);

            //act
            var setupResult = inputProcessorService.Setup(dict);

            setupResult.Match(
                failure: ex => exception = ex,
                success: _ =>
            {
                unit = _;
            }
                );

            //assert
            exception.Should().BeNull("Because the setup will succeed and return a unit");
        }
Esempio n. 2
0
        public void Should_return_an_argumentException_when_provided_a_null()
        {
            //arrange
            var dishesMenuServiceFake = A.Fake <IDishesMenuService>();
            var inputProcessorService = new InputProcessorService(dishesMenuServiceFake);
            var exception             = default(ArgumentException);

            //act
            var setupResult = inputProcessorService.Setup(null);

            setupResult.Match(
                failure: ex => exception = ex,
                success: _ => { }
                );

            //assert
            exception.Should().BeOfType(typeof(ArgumentException), "Because the setup will fail");
        }