コード例 #1
0
        public void SoldOutStateAtCreationWithZeroBalls()
        {
            var    stringWriter = new StringWriter();
            string result       = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                  $" { 0 } gumball{ ( 0 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_SOLD_OUT_STATE })";

            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(0, stringWriter);

            Assert.AreEqual(result, gumballMachine.ToString());
        }
コード例 #2
0
        public void NoQuarterStateAtCreationWithSomeBalls()
        {
            var    stringWriter = new StringWriter();
            string result       = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                  $" { 10 } gumball{ ( 10 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_NO_QUARTER_STATE })";

            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(10, stringWriter);

            Assert.AreEqual(result, gumballMachine.ToString());
        }
コード例 #3
0
        public void EjectQuarterWithZeroBalls()
        {
            var    stringWriter = new StringWriter();
            var    result       = new StringWriter();
            string gumballMachineStateResult = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                               $" { 0 } gumball{ ( 0 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_SOLD_OUT_STATE })";
            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(0, stringWriter);

            gumballMachine.EjectQuarter();
            result.WriteLine(BaseConstants.EJECT_QUARTER_SOLD_OUT_STATE);

            Assert.AreEqual(result.ToString(), stringWriter.ToString());
            Assert.AreEqual(gumballMachineStateResult, gumballMachine.ToString());
        }
コード例 #4
0
        public void InsertOneQuarterTest()
        {
            var    stringWriter = new StringWriter();
            var    result       = new StringWriter();
            string gumballMachineStateResult = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                               $" { 1 } gumball{ ( 1 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_HAS_QUARTER_STATE })";
            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(1, stringWriter);

            gumballMachine.InsertQuarter();
            result.WriteLine(BaseConstants.INSERT_QUARTER_NO_QUARTER_STATE);

            Assert.AreEqual(result.ToString(), stringWriter.ToString());
            Assert.AreEqual(gumballMachineStateResult, gumballMachine.ToString());
        }
コード例 #5
0
        public void TurnCrankWithSomeBallsAndZeroQuarterTest()
        {
            var    stringWriter = new StringWriter();
            var    result       = new StringWriter();
            string gumballMachineStateResult = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                               $" { 1 } gumball{ ( 1 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_NO_QUARTER_STATE })";
            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(1, stringWriter);

            gumballMachine.TurnCrank();
            result.WriteLine(BaseConstants.TURN_CRANK_NO_QUARTER_STATE);
            result.WriteLine(BaseConstants.DISPENSE_NO_QUARTER_STATE);

            Assert.AreEqual(result.ToString(), stringWriter.ToString());
            Assert.AreEqual(gumballMachineStateResult, gumballMachine.ToString());
        }
コード例 #6
0
        public void TurnCrankWithOneBallsAndQuartersTest()
        {
            var    stringWriter = new StringWriter();
            var    result       = new StringWriter();
            string gumballMachineStateResult = $"(Mighty Gumball, Inc.C# - enabled Standing Gumball Model #2019 (with state)Inventory:" +
                                               $" { 0 } gumball{ ( 0 != 1 ? "s" : "" ) } Machine is { BaseConstants.TO_STRING_SOLD_OUT_STATE })";
            var gumballMachine = new GumballMachine.GumballMachineWithState.GumballMachine(1, stringWriter);

            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            result.WriteLine(BaseConstants.INSERT_QUARTER_NO_QUARTER_STATE);
            result.WriteLine(BaseConstants.TURN_CRANK_HAS_QUARTER_STATE);
            result.WriteLine(BaseConstants.RELEASE_BALL);
            result.WriteLine(BaseConstants.DISPENSE_SOLD_STATE);

            Assert.AreEqual(result.ToString(), stringWriter.ToString());
            Assert.AreEqual(gumballMachineStateResult, gumballMachine.ToString());
        }