示例#1
0
        public void _Sniperが新しい金額を提示したら一位入札状態として報告を上げる()
        {
            var mockery = new MockRepository();

            var status = SniperStatus.Disconnected;

            var listener = mockery.GenerateMockHelper <ISniperListener>();

            listener.Expect(x => {
                x.SniperWinning();
            })
            .WhenCalled((m) => status = SniperStatus.Winning)
            .Repeat.AtLeastOnce();

            Func <SniperStatus> reportFunc = () => status;

            listener.Expect(x => {
                return(x.Status);
            })
            .Do(reportFunc);

            var auction = mockery.GenerateMockHelper <IAuction>();
            IAuctionEventListener sniper = new AuctionSniper.Core.AuctionSniper(auction, listener);

            sniper.CurrentPrice(123, 45, PriceSource.FromSniper);

            Assert.That(listener.Status, Is.EqualTo(SniperStatus.Winning));

            mockery.VerifyAll();
        }
        public void _1位入札でオークションを終えた場合落札状態として報告を上げる()
        {
            var mockery = new MockRepository();

            var status = SniperStatus.Disconnected;

            var listener = mockery.GenerateMockHelper<ISniperListener>();
            listener.Expect(x => {
                x.SniperBidding();
            })
            .WhenCalled((m) => status = SniperStatus.Bidding)
            .Repeat.Never();

            listener.Expect(x => {
                x.SniperWinning();
            })
            .WhenCalled((m) => status = SniperStatus.Winning)
            .Repeat.AtLeastOnce();

            listener.Expect(x => {
                x.SniperWon();
            })
            .WhenCalled((m) => status = SniperStatus.Won)
            .Repeat.Once();

            listener.Expect(x => {
                x.SniperLost();
            })
            .WhenCalled((m) => status = SniperStatus.Lost)
            .Repeat.Never();

            Func<SniperStatus> reportFunc = () => status;
            listener.Expect(x => {
                return x.Status;
            })
            .Do(reportFunc);

            var auction = mockery.GenerateMockHelper<IAuction>();
            IAuctionEventListener sniper = new AuctionSniper.Core.AuctionSniper(auction, listener);

            sniper.CurrentPrice(123, 45, PriceSource.FromSniper);
            sniper.AuctionClosed();

            Assert.That(listener.Status, Is.EqualTo(SniperStatus.Won));

            mockery.VerifyAll();
        }
示例#3
0
        public void _新しい金額が提示された場合に総額を行い報告も受ける()
        {
            var mockery = new MockRepository();

            var price = 1001;
            var inc   = 25;

            var auction = mockery.GenerateMockHelper <IAuction>();

            auction.Expect(x => {
                x.Bid(price + inc);
            });

            var status = SniperStatus.Disconnected;

            var listener = mockery.GenerateMockHelper <ISniperListener>();

            listener.Expect(x => {
                x.SniperBidding();
            })
            .WhenCalled((m) => status = SniperStatus.Bidding)
            .Repeat.AtLeastOnce();

            Func <SniperStatus> reportFunc = () => status;

            listener.Expect(x => {
                return(x.Status);
            })
            .Do(reportFunc);

            IAuctionEventListener sniper = new AuctionSniper.Core.AuctionSniper(auction, listener);

            sniper.CurrentPrice(price, inc, PriceSource.FromOtherBidder);

            Assert.That(listener.Status, Is.EqualTo(SniperStatus.Bidding));

            mockery.VerifyAll();
        }
        public void _新しい金額が提示された場合に総額を行い報告も受ける()
        {
            var mockery = new MockRepository();

            var price = 1001;
            var inc = 25;

            var auction = mockery.GenerateMockHelper<IAuction>();
            auction.Expect(x => {
                x.Bid(price+inc);
            });

            var status = SniperStatus.Disconnected;

            var listener = mockery.GenerateMockHelper<ISniperListener>();
            listener.Expect(x => {
                x.SniperBidding();
            })
            .WhenCalled((m) => status = SniperStatus.Bidding)
            .Repeat.AtLeastOnce();

            Func<SniperStatus> reportFunc = () => status;
            listener.Expect(x => {
                return x.Status;
            })
            .Do(reportFunc);

            IAuctionEventListener sniper = new AuctionSniper.Core.AuctionSniper(auction, listener);
            sniper.CurrentPrice(price, inc, PriceSource.FromOtherBidder);

            Assert.That(listener.Status, Is.EqualTo(SniperStatus.Bidding));

            mockery.VerifyAll();
        }