Beispiel #1
0
        public void Accept_CallsSpecialVisitExtension_ForSpecialVisitor()
        {
            // Arrange
            var node    = new TestExtensionIntermediateNode();
            var visitor = new SpecialVisitor();

            // Act
            node.Accept(visitor);

            // Assert
            Assert.False(visitor.WasStandardMethodCalled);
            Assert.True(visitor.WasSpecificMethodCalled);
        }
Beispiel #2
0
        public IActionResult Calculate(string visitortype)
        {
            ISwitchboardVisitor visitor = null;

            if (visitortype == "Normal")
            {
                visitor = new NormalVisitor();
            }
            else
            {
                visitor = new SpecialVisitor();
            }

            Switchboard switchboard = new Switchboard(visitor);

            switchboard.Items.Add(new Enclosure()
            {
                Cost = 50000
            });
            switchboard.Items.Add(new Transformer()
            {
                Cost = 10000
            });
            switchboard.Items.Add(new Busbars()
            {
                Cost = 5000
            });
            switchboard.Items.Add(new CircuitBreaker()
            {
                Cost = 20000
            });
            double totalCost = switchboard.Calculate();

            ViewBag.PackingShippingType = visitortype;
            ViewBag.TotalCost           = totalCost;
            return(View());
        }
Beispiel #3
0
 public override void Accept(SpecialVisitor visitor)
 {
     visitor.Visit(this);
 }
Beispiel #4
0
 public abstract void Accept(SpecialVisitor visitor);