Esempio n. 1
0
        public void CallsTheDecorateeOnce()
        {
            // Arrange
            var spy = new SpyGreeter();

            var sut = new TitledGreeterDecorator(spy);

            // Act
            sut.Greet("name");

            // Assert
            Assert.Equal(1, spy.CallCount);
        }
Esempio n. 2
0
        public void ProducesExpectedGreet()
        {
            // Arrange
            string name          = "John";
            string expectedGreet = "Hello, Mr. John.";

            var sut = new TitledGreeterDecorator(new FormalGreeter());

            // Act
            string actualGreet = sut.Greet(name);

            // Assert
            Assert.Equal(expectedGreet, actualGreet);
        }
Esempio n. 3
0
        public void ForwardsTheCallToDecorateeWithTheNamePrefixedWithTheTitle()
        {
            // Arrange
            string name = "Peter";
            string expectedSuppliedTitledName = "Mr. Peter";

            var spy = new SpyGreeter();

            var sut = new TitledGreeterDecorator(spy);

            // Act
            sut.Greet(name);

            // Assert
            Assert.Equal(expectedSuppliedTitledName, spy.SuppliedName);
        }