コード例 #1
0
ファイル: PubTests.cs プロジェクト: beardemo11/CodeWars
        public void Test_Saturday_Charge_Customer_Count()
        {
            //arrange
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
            Pub         target         = new Pub(stubCheckInFee);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            decimal expected = 3;

            //act
            var actual = target.CheckInisFemaleisFriday(customers);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void Test_Friday_Charge_Customer_Count()
        {
            //arrange
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();

            var fakeTimeWrapper = new FakeTimeWrapper();

            fakeTimeWrapper.MockTime = Convert.ToDateTime("2021/04/09"); //friday

            Pub target = new Pub(stubCheckInFee, fakeTimeWrapper);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            decimal expected = 1;

            //act
            var actual = target.CheckIn(customers);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void Test_Income_顧客1男2女_應回傳收費人數1人_模擬每一人收費為100元_預期結果門票收入總數為100_使用RhinoMocks物件()
        {
            //arrange
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
            Pub         target         = new Pub(stubCheckInFee);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            var inComeBeforeCheckIn = target.GetInCome();

            Assert.AreEqual(0, inComeBeforeCheckIn);

            decimal expectedIncome = 100;

            //act
            var chargeCustomerCount = target.CheckIn(customers);

            var actualIncome = target.GetInCome();

            //assert
            Assert.AreEqual(expectedIncome, actualIncome);
        }
コード例 #4
0
        public void CheckInTest_顧客1男2女_應回傳收費人數1人_使用RhinoMocks物件()
        {
            //arrange準備受測物件、參數、預期結果
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
            Pub         target         = new Pub(stubCheckInFee);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            decimal expected = 1;

            //act執行受測方法
            var actual = target.CheckIn(customers);

            //assert驗證執行結果與預測結果是否一致
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void CheckInTest_Customer_2女1男_應收費人數為1()
        {
            //arrange
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
            Pub         target         = new Pub(stubCheckInFee);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            decimal expected = 1;

            //act
            var actual = target.CheckIn(customers);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
ファイル: PubTests.cs プロジェクト: HughChiou/TDD30Days
        public void GetInComeTest()
        {
            //arrange
            ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
            Pub         target         = new Pub(stubCheckInFee);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                }
            };

            var inComeBeforeCheckIn = target.GetInCome();

            Assert.AreEqual(0, inComeBeforeCheckIn);

            decimal expectedIncome = 200;

            //act
            var chargeCustomerCount = target.CheckIn(customers);

            var actualIncome = target.GetInCome();

            //assert
            Assert.AreEqual(expectedIncome, actualIncome);
        }
コード例 #7
0
        public void Test_Friday_Charge_Customer_Count()
        {
            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.TodayGet = () =>
                {
                    //2012/10/19為Friday
                    return(new DateTime(2012, 10, 19));
                };


                //arrange
                ICheckInFee stubCheckInFee = MockRepository.GenerateStub <ICheckInFee>();
                Pub         target         = new Pub(stubCheckInFee);

                stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

                var cusomers = new List <Customer>
                {
                    new Customer()
                    {
                        IsMale = true
                    },
                    new Customer()
                    {
                        IsMale = false
                    },
                    new Customer()
                    {
                        IsMale = false
                    },
                };

                decimal expected = 1;

                //act
                var actual = target.CheckIn(cusomers);

                //assert
                Assert.AreEqual(expected, actual);
            }
        }
コード例 #8
0
        public void Test_Income()
        {
            //arrange
            ICheckInFee stubCheckInFee  = MockRepository.GenerateStub <ICheckInFee>();
            var         fakeTimeWrapper = new FakeTimeWrapper();

            fakeTimeWrapper.MockTime = Convert.ToDateTime("2021/04/09");
            Pub target = new Pub(stubCheckInFee, fakeTimeWrapper);

            stubCheckInFee.Stub(x => x.GetFee(Arg <Customer> .Is.Anything)).Return(100);

            var customers = new List <Customer>
            {
                new Customer {
                    IsMale = true
                },
                new Customer {
                    IsMale = false
                },
                new Customer {
                    IsMale = false
                },
            };

            var inComeBeforeCheckIn = target.GetInCome();

            Assert.AreEqual(0, inComeBeforeCheckIn);

            decimal expectedIncome = 100;

            //act
            var chargeCustomerCount = target.CheckIn(customers);
            var actualIncome        = target.GetInCome();

            //assert
            Assert.AreEqual(expectedIncome, actualIncome);
        }