示例#1
0
    public void testListForwardsToDataModel()
    {
        WebAPI.IShopActions            shop_actions = mock.NewMock <WebAPI.IShopActions>();
        Roar.implementation.IDataStore datastore    = mock.NewMock <Roar.implementation.IDataStore>();
        Roar.ILogger logger = mock.NewMock <Roar.ILogger>();
        Roar.implementation.Components.Shop shop = new Roar.implementation.Components.Shop(shop_actions, datastore, logger);

        IDataModel <Roar.DomainObjects.ShopEntry, Roar.WebObjects.Shop.ListResponse> shop_datamodel = mock.NewMock <IDataModel <Roar.DomainObjects.ShopEntry, Roar.WebObjects.Shop.ListResponse> >();

        List <Roar.DomainObjects.ShopEntry> retval = new List <Roar.DomainObjects.ShopEntry>();

        retval.Add(new Roar.DomainObjects.ShopEntry());
        retval.Add(new Roar.DomainObjects.ShopEntry());

        Expect.AtLeast(1).On(datastore)
        .GetProperty("shop")
        .Will(Return.Value(shop_datamodel));

        Expect.AtLeast(1).On(shop_datamodel)
        .Method("List")
        .Will(Return.Value(retval));

        IList <Roar.DomainObjects.ShopEntry> l = shop.List();

        Assert.AreEqual(2, l.Count);

        mock.VerifyAllExpectationsHaveBeenMet();
    }
        public void TestConstructorWithAlreadyEndedTransaction()
        {
            WeightedTransaction <Transaction> testTransaction = new WeightedTransaction <Transaction>(
                Transaction.EndedDummy
                );

            IObservationSubscriber subscriber = this.mockery.NewMock <IObservationSubscriber>();

            Expect.AtLeast(0).On(subscriber).Method("ProgressUpdated");
            // This should no be called because otherwise, the 'Ended' event would be raised
            // to the transaction group before all transactions have been added into
            // the internal list, leading to an early ending or even multiple endings.
            Expect.Never.On(subscriber).Method("Ended");

            using (
                ObservedWeightedTransaction <Transaction> test =
                    new ObservedWeightedTransaction <Transaction>(
                        testTransaction,
                        new ObservedWeightedTransaction <Transaction> .ReportDelegate(
                            subscriber.ProgressUpdated
                            ),
                        new ObservedWeightedTransaction <Transaction> .ReportDelegate(
                            subscriber.Ended
                            )
                        )
                ) {
                this.mockery.VerifyAllExpectationsHaveBeenMet();
            }
        }
        public void TestConstructorWithEndingTransaction()
        {
            WeightedTransaction <Transaction> testTransaction = new WeightedTransaction <Transaction>(
                new FunkyTransaction()
                );

            IObservationSubscriber subscriber = this.mockery.NewMock <IObservationSubscriber>();

            Expect.AtLeast(0).On(subscriber).Method("ProgressUpdated");
            Expect.Once.On(subscriber).Method("Ended");

            using (
                ObservedWeightedTransaction <Transaction> test =
                    new ObservedWeightedTransaction <Transaction>(
                        testTransaction,
                        new ObservedWeightedTransaction <Transaction> .ReportDelegate(
                            subscriber.ProgressUpdated
                            ),
                        new ObservedWeightedTransaction <Transaction> .ReportDelegate(
                            subscriber.Ended
                            )
                        )
                ) {
                this.mockery.VerifyAllExpectationsHaveBeenMet();
            }
        }
示例#4
0
        private void SetupGiven(ref Mockery mocks, ref SimplestPossibleWorld world)
        {
            IGiven given = (IGiven)mocks.NewMock <IGiven>();

            Expect.AtLeast(1).On(given).Method("Setup").With(world);
            List <IGiven> GivenCollection = new List <IGiven>();

            GivenCollection.Add(given);
        }
示例#5
0
        private void SetupWorldOutcome(ref Mockery mocks, ref SimplestPossibleWorld world)
        {
            IWorldOutcome outcome = mocks.NewMock <IWorldOutcome>();

            Expect.AtLeast(1).On(outcome).Method("Verify").With(world);
            Expect.AtLeast(1).On(outcome).GetProperty("Result").Will(Return.Value(CreateSuccessfulOutcome()));
            List <IWorldOutcome> outcomeCollection = new List <IWorldOutcome>();

            outcomeCollection.Add(outcome);
        }
示例#6
0
        public void ExpectInvokedAtLeastNTimes()
        {
            Expect.AtLeast(3).MethodCall(() => myObject.MyEmptyMethod());

            myObject.MyEmptyMethod();
            myObject.MyEmptyMethod();
            myObject.MyEmptyMethod();
            myObject.MyEmptyMethod();
            myObject.MyEmptyMethod();
        }
示例#7
0
        public void TestRenderNormal()
        {
            // Make sure the renderer draws at least two frames
            Expect.AtLeast(2).On(MockedGraphics).Method("DrawElement").WithAnyArguments();

            // Let the renderer draw the progress bar into the mocked graphics interface
            renderer.Render(this.progress, MockedGraphics);

            // And verify the expected drawing commands were issues
            Mockery.VerifyAllExpectationsHaveBeenMet();
        }
示例#8
0
        private IScenario SetupScenario(ref Mockery mocks, ref SimplestPossibleWorld world)
        {
            IScenario scenario = mocks.NewMock <IScenario>();

            Expect.AtLeast(1).On(scenario).Method("SetupWorld").Will(Return.Value(world));
            Expect.AtLeast(0).On(scenario).SetProperty("World").To(world);
            Expect.AtLeast(0).On(scenario).GetProperty("World").Will(Return.Value(world));
            Expect.AtLeast(1).On(scenario).Method("Specify");

            Outcome o = CreateSuccessfulOutcome();

            Expect.AtLeast(1).On(scenario).Method("Run").Will(Return.Value(o));

            return(scenario);
        }
        /// <summary>
        ///   Lets the renderer draw the list and verifies that the list used
        ///   the skin elements from the expected state
        /// </summary>
        private void drawAndExpectState()
        {
            // Make sure the renderer draws the list frame
            Expect.Once.On(MockedGraphics).Method("DrawElement").WithAnyArguments();
            Expect.AtLeastOnce.On(MockedGraphics).Method("SetClipRegion").WithAnyArguments();
            Expect.AtLeast(0).On(MockedGraphics).Method("MeasureString").WithAnyArguments().Will(
                Return.Value(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f))
                );
            Expect.AtLeast(0).On(MockedGraphics).Method("DrawElement").WithAnyArguments();
            Expect.AtLeast(2).On(MockedGraphics).Method("DrawString").WithAnyArguments();

            // Let the renderer draw the list into the mocked graphics interface
            renderer.Render(this.list, MockedGraphics);

            // And verify the expected drawing commands were issues
            Mockery.VerifyAllExpectationsHaveBeenMet();
        }
示例#10
0
        public void TestRenderNormal()
        {
            // Make sure the renderer draws at least the input control's text
            Expect.AtLeast(0).On(MockedGraphics).Method("MeasureString").WithAnyArguments().Will(
                Return.Value(new RectangleF(0.0f, 0.0f, 200.0f, 10.0f))
                );
            Expect.AtLeast(0).On(MockedGraphics).Method("SetClipRegion").WithAnyArguments();
            Expect.AtLeast(0).On(MockedGraphics).Method("DrawCaret").WithAnyArguments();
            Expect.Once.On(MockedGraphics).Method("DrawElement").WithAnyArguments();
            Expect.Once.On(MockedGraphics).Method("DrawString").WithAnyArguments();

            // Let the renderer draw the input control into the mocked graphics interface
            renderer.Render(this.input, MockedGraphics);

            // And verify the expected drawing commands were issues
            Mockery.VerifyAllExpectationsHaveBeenMet();
        }
示例#11
0
        void HackVerifyShutdown(Mockery mkry, IBluesoleilApi api, BluesoleilFactory fcty)
        {
            GC.KeepAlive(fcty);
            Expect.Once.On(api).Method("Btsdk_Disconnect")
            .WithAnyArguments()
            .Will(Return.Value(BtSdkError.OK));
#if true
            Expect.AtLeast(0).On(api).Method("Btsdk_Done")
            .WithAnyArguments()
            .Will(Return.Value(BtSdkError.OK));
            //
#else
            fcty = null;
            cli  = null;
            Expect.Once.On(api).Method("Btsdk_Done")
            .WithAnyArguments()
            .Will(Return.Value(BtSdkError.OK));
            WaitForFinalizers();
            WaitForFinalizers();
            mkry.VerifyAllExpectationsHaveBeenMet();
#endif
        }
示例#12
0
        private void SetupEvent(ref Mockery mocks, ref SimplestPossibleWorld world)
        {
            IEvent evt = mocks.NewMock <IEvent>();

            Expect.AtLeast(1).On(evt).Method("OccurIn").With(world);
        }