Exemplo n.º 1
0
        public void CreateCoffee_ShouldThrowArgumentNullException_WhenInvalidParameterPassed()
        {
            // Arange
            var           condimentsStrategiesMock = new Mock <IDictionary <string, Func <ICoffee, ICoffee> > >();
            var           coffeetypeStrategiesMock = new Mock <IDictionary <string, Func <CoffeSizeType, ICoffee> > >();
            string        coffeeType = "Espresso";
            CoffeSizeType size       = CoffeSizeType.Medium;

            coffeetypeStrategiesMock.Setup(d => d.ContainsKey(coffeeType)).Returns(false);

            var sofiaStore = new SofiaCoffeeStoreFake(condimentsStrategiesMock.Object, coffeetypeStrategiesMock.Object);

            //Act & Assert
            Assert.That(() => sofiaStore.ExposedCreateCoffee(coffeeType, size), Throws.InstanceOf <ArgumentNullException>());
        }
Exemplo n.º 2
0
        public void CreateCoffee_ShouldReturnICoffeeObject_WhenValidParameterPassed()
        {
            // Arange
            var           condimentsStrategiesMock = new Mock <IDictionary <string, Func <ICoffee, ICoffee> > >();
            var           coffeetypeStrategiesMock = new Mock <IDictionary <string, Func <CoffeSizeType, ICoffee> > >();
            string        coffeeType           = "Espresso";
            CoffeSizeType size                 = CoffeSizeType.Medium;
            Func <CoffeSizeType, ICoffee> func = s => new Espresso(s);

            coffeetypeStrategiesMock.Setup(d => d.ContainsKey(coffeeType)).Returns(true);
            coffeetypeStrategiesMock.Setup(d => d[coffeeType]).Returns(func);

            var sofiaStore = new SofiaCoffeeStoreFake(condimentsStrategiesMock.Object, coffeetypeStrategiesMock.Object);
            // Act
            var result = sofiaStore.ExposedCreateCoffee(coffeeType, size);

            //Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <ICoffee>());
        }