示例#1
0
        public void _オークションが閉じたときに落札に失敗したことの報告を受ける()
        {
            var mockery = new MockRepository();

            var status = SniperStatus.Disconnected;

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

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

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

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

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

            sniper.AuctionClosed();

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

            listener.VerifyAllExpectations();
        }
示例#2
0
        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();
        }
        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();
        }
        public void _オークションが閉じたときに落札に失敗したことの報告を受ける()
        {
            var mockery = new MockRepository();

            var status = SniperStatus.Disconnected;

            var listener = mockery.GenerateMockHelper<ISniperListener>();
            listener.Expect(x => {
                x.SniperLost();
            })
            .WhenCalled((m) => status = SniperStatus.Lost)
            .Repeat.Once();

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

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

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

            listener.VerifyAllExpectations();
        }