public void VerifyUserAgent(string expected)
        {
            var mock = new DynamicMock(typeof(IAndroidJavaClass));

            mock.ExpectAndReturn("CallStatic", "1.0.0", "GetSdkVersion");
            Assert.AreEqual(
                string.Format(
                    CultureInfo.InvariantCulture,
                    expected,
                    FacebookSdkVersion.Build),
                Constants.GraphApiUserAgent);
        }
Beispiel #2
0
        public void Setup()
        {
            serverSpecifier   = new DefaultServerSpecifier(serverName);
            projectSpecifier  = new DefaultProjectSpecifier(serverSpecifier, projectName);
            buildSpecifier    = new DefaultBuildSpecifier(projectSpecifier, buildName);
            linkFactoryMock   = new DynamicMock(typeof(ILinkFactory));
            configurationMock = new DynamicMock(typeof(IPluginConfiguration));
            Plugins           = new DefaultPluginLinkCalculator((ILinkFactory)linkFactoryMock.MockInstance, (IPluginConfiguration)configurationMock.MockInstance);

            pluginMock1 = new DynamicMock(typeof(IPlugin));
            pluginMock2 = new DynamicMock(typeof(IPlugin));
            action1     = new ImmutableNamedAction("Action Name 1", null);
            action2     = new ImmutableNamedAction("Action Name 2", null);
            action3     = new ImmutableNamedAction("Action Name 3", null);
            pluginMock1.ExpectAndReturn("LinkDescription", "Description 1");
            pluginMock1.ExpectAndReturn("NamedActions", new INamedAction[] { action1 });
            pluginMock2.ExpectAndReturn("LinkDescription", "Description 2");
            pluginMock2.ExpectAndReturn("NamedActions", new INamedAction[] { action2 });
            link1 = (IAbsoluteLink) new DynamicMock(typeof(IAbsoluteLink)).MockInstance;
            link2 = (IAbsoluteLink) new DynamicMock(typeof(IAbsoluteLink)).MockInstance;
        }
        private void PrepareConfirmationPageMocks(bool result, params int[] variant)
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock canvas = AddElementMock(typeof(IHTMLElement));

            documentMock.ExpectAndReturn("getElementById", canvas.MockInstance, "canvas");
            if (result == false)
            {
                canvas.ExpectAndReturn("get_innerHTML", "some text");
                return;
            }

            if (variant[0] == 1)
            {
                canvas.ExpectAndReturn("get_innerHTML", "<p>some html</p><div>Dyspozycja Przelewu zosta³a przyjêta i zostanie wykonana<br>Zgodnie z zasadami Obowi¹zuj¹cymi W Banku.</div>");
            }
            else
            {
                canvas.ExpectAndReturn("get_innerHTML", "<p>some html</p><div>Zlecenie&nbsp;zosta³o Wys³ane.</div>");
            }
        }
        public void DefaultPowerShellShouldBe2IfInstalled()
        {
            IMock mockRegistry2 = new DynamicMock(typeof(IRegistry));

            PowerShellTask task = new PowerShellTask((IRegistry)mockRegistry2.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance);

            mockRegistry2.ExpectAndReturn("GetLocalMachineSubKeyValue", POWERSHELL2_PATH,
                                          PowerShellTask.regkeypowershell2, PowerShellTask.regkeyholder);
            Assert.AreEqual(POWERSHELL2_PATH + "\\powershell.exe", task.Executable);
            mockRegistry2.Verify();
            mockProcessExecutor.Verify();
        }
        private void PrepareConfirmPageMocks(bool result, String amountPaid, String enteredAccountNo)
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock docHeader = AddElementMock(typeof(IHTMLElement));

            documentMock.ExpectAndReturn("getElementById", docHeader.MockInstance, "docheader");
            if (result == false)
            {
                docHeader.ExpectAndReturn("get_innerHTML", "some text");
                return;
            }

            if (paymentInfo.IsDefinedTransfer == false)
            {
                docHeader.ExpectAndReturn("get_innerHTML", "<p>some text</p><h1>Potwierdzenie&nbsp;Zlecenia Przelewu Jednorazowego</h1>");
            }
            else
            {
                docHeader.ExpectAndReturn("get_innerHTML", "<p>some text</p><h1>Potwierdzenie&nbsp;realizacji P³atnoœci</h1>");
            }

            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock tdElems = AddElementMock(typeof(IHTMLElementCollection));

            documentMock.ExpectAndReturn("getElementsByTagName", tdElems.MockInstance, "td");
            ArrayList   tdList = new ArrayList();
            DynamicMock td     = AddElementMock(typeof(IHTMLElement));

            td.ExpectAndReturn("get_innerHTML", "some td value");
            tdList.Add(td.MockInstance);

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", "Numer&nbsp;Rachunku Odbiorcy");
            tdList.Add(td.MockInstance);

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", "&nbsp;" + enteredAccountNo + "&nbsp;<table></table>");
            tdList.Add(td.MockInstance);

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", "some other td value");
            tdList.Add(td.MockInstance);

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", "Kwota&nbsp;");
            tdList.Add(td.MockInstance);

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", amountPaid + "&nbsp;PLN");
            tdList.Add(td.MockInstance);

            tdElems.ExpectAndReturn("GetEnumerator", tdList.GetEnumerator());
        }
Beispiel #6
0
        private void PrepareLoggedUserMocks()
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            documentMock.ExpectAndReturn("get_url", "https://bank/url/centrum24-web/");

            DynamicMock aElems = AddElementMock(typeof(IHTMLElementCollection));

            documentMock.ExpectAndReturn("getElementsByTagName", aElems.MockInstance, "a");

            ArrayList   aList = new ArrayList();
            DynamicMock a     = AddElementMock(typeof(IHTMLElement));

            a.ExpectAndReturn("get_innerHTML", "some text");
            aList.Add(a.MockInstance);

            a = AddElementMock(typeof(IHTMLElement));
            a.ExpectAndReturn("get_innerHTML", "&nbsp;WyLoguj");
            aList.Add(a.MockInstance);

            aElems.ExpectAndReturn("GetEnumerator", aList.GetEnumerator());
        }
Beispiel #7
0
        public void DefaultVisualStudioShouldBe2010IfNothingNewerInstalled()
        {
            IMock mockRegistry2 = new DynamicMock(typeof(IRegistry));

            DevenvTask task2 = new DevenvTask((IRegistry)mockRegistry2.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance);

            mockRegistry2.ExpectAndReturn("GetLocalMachineSubKeyValue", DEVENV_2010_PATH,
                                          DevenvTask.VS2010_REGISTRY_PATH, DevenvTask.VS_REGISTRY_KEY);
            Assert.AreEqual(DEVENV_2010_PATH + "devenv.com", task2.Executable);
            mockRegistry2.Verify();
            mockProcessExecutor.Verify();
        }
        public void ShouldReturnDefaultOption()
        {
            DynamicMock webBrowser   = new DynamicMock(typeof(IE.WebBrowser));
            DynamicMock documentMock = new DynamicMock(typeof(HTMLDocument));

            webBrowser.ExpectAndReturn("get_Document", documentMock.MockInstance);
            documentMock.ExpectAndReturn("get_url", "http://someLink/");
            PaymentRequest request = new PaymentRequest(webBrowser.MockInstance as IE.WebBrowser, PaymentInfo.ValueOf(""));

            Assert.AreEqual("http://someLink/", request.Url);
            Assert.AreEqual("http://someLink/", request.Url);
        }
Beispiel #9
0
    public RejectInvalidStateAbbreviation()
    {
        IMock mock = new DynamicMock(typeof(ITaxCalculator));

        mock.ExpectAndReturn("CalculateTax", 7.25, 100, "TX");
        mock.ExpectAndReturn("CalculateTax", 7.00, 100, "NC");
        mock.ExpectAndThrow("CalculateTax",
                            new ArgumentException(), 100, "XX");

        ITaxCalculator calc = mock.Object as ITaxCalculator;

        Assert.That(
            calc.CalculateTax(100, "TX"),
            Is.EqualTo(7.25)
            );
        Assert.That(
            calc.CalculateTax(100, "NC"),
            Is.EqualTo(7.00));

        calc.CalculateTax(100, "XX");
    }
Beispiel #10
0
        /// <summary>
        /// Returns an IXWikiClient mock implementation to be used by unit tests.
        /// </summary>
        /// <returns>An IXWikiClient mock instance.</returns>
        public static IXWikiClient CreateMockInstance()
        {
            DynamicMock xWikiClientMock = new DynamicMock(typeof(IXWikiClient));

            xWikiClientMock.ExpectAndReturn("Login", true, new object[2]);
            xWikiClientMock.ExpectAndReturn("GetAvailableSyntaxes", new List <string>()
            {
                "XWiki 2.0", "XHTML"
            });
            xWikiClientMock.ExpectAndReturn("GetPagesNames", new List <string>()
            {
                "Page1"
            }, new object[1]);
            xWikiClientMock.ExpectAndReturn("SavePageHTML", true, new object[3]);
            xWikiClientMock.ExpectAndReturn("AddAttachment", true, new object[2] {
                PAGE_FULL_NAME, "localFolder\\Document1_TempExport_files/image002.jpg"
            });
            xWikiClientMock.ExpectAndReturn("GetAttachmentURL", "http://127.0.0.1:8080/xwiki/bin/download/Main/Page1/image002.jpg", new object[] { PAGE_FULL_NAME, "image002.jpg" });


            SetObjSummariesForGetObjects(ref xWikiClientMock);

            SetObjForGetObject(ref xWikiClientMock);

            return((IXWikiClient)xWikiClientMock.MockInstance);
        }
Beispiel #11
0
        public void ShouldGenerateFarmServerAndProjectLinksIfServerAndProjectButNoBuildSpecified()
        {
            // Setup
            cruiseRequestMock.ExpectAndReturn("ServerName", "myServer");
            cruiseRequestMock.ExpectAndReturn("ServerName", "myServer");
            cruiseRequestMock.ExpectAndReturn("ProjectName", "myProject");
            cruiseRequestMock.ExpectAndReturn("ProjectName", "myProject");
            cruiseRequestMock.ExpectAndReturn("ProjectName", "myProject");
            cruiseRequestMock.ExpectAndReturn("BuildName", "");
            cruiseRequestMock.ExpectAndReturn("ServerSpecifier", serverSpecifier);
            cruiseRequestMock.ExpectAndReturn("ServerSpecifier", serverSpecifier);
            cruiseRequestMock.ExpectAndReturn("ProjectSpecifier", projectSpecifier);
            cruiseRequestMock.ExpectAndReturn("Request", requestMock.MockInstance);
            requestMock.ExpectAndReturn("GetText", "", new object[] { "Category" });

            ProjectStatus ps = new ProjectStatus("myProject", "", null, 0, 0, null, DateTime.Now, null, null, DateTime.Now, null, "Queue 1", 1, new List <ParameterBase>());

            ProjectStatusOnServer[]        psosa = new ProjectStatusOnServer[] { new ProjectStatusOnServer(ps, serverSpecifier) };
            ProjectStatusListAndExceptions pslae = new ProjectStatusListAndExceptions(psosa, new CruiseServerException[0]);

            farmServiceMock.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", pslae, serverSpecifier, null);

            expectedVelocityContext["serverName"]   = "myServer";
            expectedVelocityContext["categoryName"] = "";
            expectedVelocityContext["projectName"]  = "myProject";
            expectedVelocityContext["buildName"]    = "";

            linkFactoryMock.ExpectAndReturn("CreateFarmLink", link1, "Dashboard", FarmReportFarmPlugin.ACTION_NAME);
            linkFactoryMock.ExpectAndReturn("CreateServerLink", link2, serverSpecifier, ServerReportServerPlugin.ACTION_NAME);
            linkFactoryMock.ExpectAndReturn("CreateProjectLink", link3, projectSpecifier, ProjectReportProjectPlugin.ACTION_NAME);
            expectedVelocityContext["farmLink"]    = link1;
            expectedVelocityContext["serverLink"]  = link2;
            expectedVelocityContext["projectLink"] = link3;

            velocityViewGeneratorMock.ExpectAndReturn("GenerateView", response, "TopMenu.vm", new HashtableConstraint(expectedVelocityContext));

            // Execute & Verify
            Assert.AreEqual(response, viewBuilder.Execute());
            VerifyAll();
        }
        public void testStrategy()
        {
            FastIDSet itemIDsFromUser123 = new FastIDSet();

            itemIDsFromUser123.Add(1L);

            FastIDSet itemIDsFromUser456 = new FastIDSet();

            itemIDsFromUser456.Add(1L);
            itemIDsFromUser456.Add(2L);

            List <IPreference> prefs = new List <IPreference>();

            prefs.Add(new GenericPreference(123L, 1L, 1.0f));
            prefs.Add(new GenericPreference(456L, 1L, 1.0f));
            IPreferenceArray preferencesForItem1 = new GenericItemPreferenceArray(prefs);

            var dataModelMock = new DynamicMock(typeof(IDataModel));

            dataModelMock.ExpectAndReturn("GetPreferencesForItem", preferencesForItem1, (1L));
            dataModelMock.ExpectAndReturn("GetItemIDsFromUser", itemIDsFromUser123, (123L));
            dataModelMock.ExpectAndReturn("GetItemIDsFromUser", itemIDsFromUser456, (456L));

            IPreferenceArray prefArrayOfUser123 =
                new GenericUserPreferenceArray(new List <IPreference>()
            {
                new GenericPreference(123L, 1L, 1.0f)
            });

            ICandidateItemsStrategy strategy = new PreferredItemsNeighborhoodCandidateItemsStrategy();

            //EasyMock.replay(dataModel);

            FastIDSet candidateItems = strategy.GetCandidateItems(123L, prefArrayOfUser123, (IDataModel)dataModelMock.MockInstance);

            Assert.AreEqual(1, candidateItems.Count());
            Assert.True(candidateItems.Contains(2L));

            dataModelMock.Verify(); //  EasyMock.verify(dataModel);
        }
Beispiel #13
0
        public void PublishUserAchievements()
        {
            User user = new User {
                SteamUserId = "user1", FacebookUserId = 1, AccessToken = "token", AutoUpdate = true
            };

            _userServiceMock.ExpectAndReturn("GetUser", user, "user1");
            _achievementServiceMock.ExpectAndReturn("UpdateAchievements", 1, "user1");
            _achievementServiceMock.ExpectAndReturn("GetUnpublishedAchievements",
                                                    new List <SimpleAchievement>
            {
                new SimpleAchievement
                {
                    Id          = 1,
                    Name        = "achievement 1",
                    Description = "x",
                    ImageUrl    = "http://example.com/a.jpg",
                    Game        =
                        new Game
                    {
                        Id       = 1,
                        Name     = "game 1",
                        ImageUrl = "http://example.com/g.jpg",
                        StatsUrl = "http://example.com/stats",
                        StoreUrl = "http://example.com/store"
                    }
                }
            },
                                                    "user1", DateTime.UtcNow.AddDays(-2).Date);
            _publisherMock.Expect("Publish");
            _achievementServiceMock.ExpectAndReturn("PublishAchievements", true, "user1", new List <int> {
                1
            });

            _manager.PublishUserAchievements(user.SteamUserId);

            _achievementServiceMock.Verify();
            _publisherMock.Verify();
            _userServiceMock.Verify();
        }
        private void PrepareConfirmPage(String enteredAmount, String enteredAccountNo)
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock elementMock = AddElementMock(typeof(IHTMLElement));

            if (paymentInfo.IsDefinedTransfer == false)
            {
                documentMock.ExpectAndReturn("getElementById", elementMock.MockInstance, MBankProvider.TRANSFER_EXEC_DIV);
            }
            else
            {
                documentMock.ExpectAndReturn("getElementById", null, MBankProvider.TRANSFER_EXEC_DIV);
                browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
                documentMock.ExpectAndReturn("getElementById", elementMock.MockInstance, MBankProvider.DEFINED_TRANSFER_EXEC_DIV);
            }

            elementMock.ExpectAndReturn("get_innerHTML", "<span class=\"text amount\">" + enteredAmount + "</span>");
            ArrayList   divChildren = new ArrayList();
            DynamicMock element     = AddElementMock(typeof(IHTMLElement));

            element.ExpectAndReturn("get_innerHTML", "nothing");
            divChildren.Add(element.MockInstance);

            element = AddElementMock(typeof(IHTMLElement));
            element.ExpectAndReturn("get_innerHTML", "Rachunek odbiorcy");
            divChildren.Add(element.MockInstance);

            element = new DynamicMock(typeof(IHTMLElement));
            element.ExpectAndReturn("get_innerHTML", "nothing");
            divChildren.Add(element.MockInstance);

            element = new DynamicMock(typeof(IHTMLElement));
            element.ExpectAndReturn("get_innerHTML", enteredAccountNo);
            divChildren.Add(element.MockInstance);

            DynamicMock collection = AddElementMock(typeof(IHTMLElementCollection));

            collection.ExpectAndReturn("GetEnumerator", divChildren.GetEnumerator());
            elementMock.ExpectAndReturn("get_all", collection.MockInstance);
        }
        public void OnRestartKillAllIntegratorsRefreshConfigAndStartupNewIntegrators()
        {
            integratorMock1.Expect("Start");
            integratorMock2.Expect("Start");

            server.Start();

            integratorMock1.Expect("Stop", true);
            integratorMock1.Expect("WaitForExit");
            integratorMock2.Expect("Stop", true);
            integratorMock2.Expect("WaitForExit");

            configuration = new Configuration();
            configuration.AddProject(project1);
            integratorList = new ProjectIntegratorList();
            integratorList.Add(integrator1);
            configServiceMock.ExpectAndReturn("Load", configuration);
            projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue);

            integratorMock1.Expect("Start");
            integratorMock2.ExpectNoCall("Start");

            server.Restart();

            VerifyAll();
        }
        public void ErrorsWhileGettingTheReferenceToTheServiceAreVisibleToTheUser()
        {
            DynamicMock mockFactory = new DynamicMock(typeof(ISpringServiceFactory));
            DynamicMock mockService = new DynamicMock(typeof(ISpringService));

            mockService.ExpectAndThrow("DeployInformations", new Exception("this and that"));
            mockFactory.ExpectAndReturn("SpringService", mockService.Object);

            monitor.ServiceFactory = mockFactory.Object as ISpringServiceFactory;
            Assert.AreEqual("service not available: this and that", serviceStatus.Text);
            Assert.AreEqual(String.Empty, appStatus.Text);
            ScreenShot("service not available.gif");
        }
        private void AddTransfer(String definedTransfer, ArrayList tdList, bool click)
        {
            DynamicMock mock = AddElementMock(typeof(IHTMLElement));

            mock.ExpectAndReturn("get_innerHTML", "<INPUT name=parRadio>something</INPUT>");
            DynamicMock forms    = AddElementMock(typeof(IHTMLElementCollection));
            ArrayList   formList = new ArrayList();
            DynamicMock form     = AddElementMock(typeof(IHTMLElement));

            if (click == true)
            {
                form.Expect("click");

                DynamicMock window = AddElementMock(typeof(IHTMLWindow2));
                window.Expect("execScript", "Execute()", "JScript");
                documentMock.ExpectAndReturn("get_parentWindow", window.MockInstance);
            }
            formList.Add(form.MockInstance);

            forms.ExpectAndReturn("GetEnumerator", formList.GetEnumerator());
            mock.ExpectAndReturn("get_all", forms.MockInstance);
            tdList.Add(mock.MockInstance);

            ArrayList aList = new ArrayList();

            aList.Add(AddElementMock(typeof(IHTMLElement)));

            mock = AddElementMock(typeof(IHTMLElement));
            mock.ExpectAndReturn("get_innerHTML", definedTransfer);
            aList.Add(mock.MockInstance);

            DynamicMock aElements = AddElementMock(typeof(IHTMLElementCollection));

            aElements.ExpectAndReturn("GetEnumerator", aList.GetEnumerator());

            mock = AddElementMock(typeof(IHTMLElement));
            mock.ExpectAndReturn("get_all", aElements.MockInstance);
            tdList.Add(mock.MockInstance);
        }
Beispiel #18
0
        public void ReturnsServerLogFromRequestedServer()
        {
            // Setup
            IServerSpecifier serverSpecifier   = new DefaultServerSpecifier("foo");
            string           serverLog         = "server log";
            Hashtable        expectedHashtable = new Hashtable();

            expectedHashtable["log"]          = serverLog;
            expectedHashtable["projectLinks"] = new IsAnything();

            IResponse response = new HtmlFragmentResponse("foo");

            requestMock.SetupResult("ServerSpecifier", serverSpecifier);
            farmServiceMock.ExpectAndReturn("GetServerLog", serverLog, serverSpecifier, null);
            farmServiceMock.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", new ProjectStatusListAndExceptions(new ProjectStatusOnServer[0], null), serverSpecifier, null);
            viewGeneratorMock.ExpectAndReturn("GenerateView", response, @"ServerLog.vm", new HashtableConstraint(expectedHashtable));

            // Execute
            Assert.AreEqual(response, action.Execute((ICruiseRequest)requestMock.MockInstance));

            VerifyAll();
        }
        private void PrepareSelectAccountAndGoToTransferPageMocks(int count)
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock accountsGrid = AddElementMock(typeof(IHTMLElement));

            documentMock.ExpectAndReturn("getElementById", accountsGrid.MockInstance, "AccountsGrid");

            PrepareGetIdListMocks(count, accountsGrid, "AccountsGrid_grid_ctl_");

            for (int i = 0; i < count + 1; i++)
            {
                DynamicMock account = AddElementMock(typeof(IHTMLElement));
                documentMock.ExpectAndReturn("getElementById", account.MockInstance, "AccountsGrid_grid_ctl_" + i + "__");
                switch (i)
                {
                case 0:
                    account.ExpectAndReturn("get_innerHTML", "eMAX Plus");
                    break;

                default:
                    account.ExpectAndReturn("get_innerHTML", MBankProvider.SUPPORTED_ACCOUNTS[i - 1]);
                    break;
                }
            }

            if (count == 1)
            {
                DynamicMock account = AddElementMock(typeof(IHTMLElement));
                account.Expect("click");
                if (paymentInfo.IsDefinedTransfer == false)
                {
                    documentMock.ExpectAndReturn("getElementById", account.MockInstance, "AccountsGrid_grid_ctl_1_3_A0");
                }
                else
                {
                    documentMock.ExpectAndReturn("getElementById", account.MockInstance, "AccountsGrid_grid_ctl_1_3_A2");
                }
            }
        }
        private void PrepareConfirmPageMocks(String amountPaid, String enteredAccountNo)
        {
            browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance);
            DynamicMock elements = new DynamicMock(typeof(IHTMLElementCollection));

            documentMock.ExpectAndReturn("getElementsByTagName", elements.MockInstance, "td");

            ArrayList   tdList      = new ArrayList();
            DynamicMock elementMock = AddElementMock(typeof(IHTMLElement));

            elementMock.ExpectAndReturn("get_innerHTML", "anything");
            elementMock.ExpectAndReturn("get_innerHTML", "anything");
            tdList.Add(elementMock.MockInstance);

            elementMock = AddElementMock(typeof(IHTMLElement));
            elementMock.ExpectAndReturn("get_innerHTML", "Numer rachunku odbiorcy");
            elementMock.ExpectAndReturn("get_innerHTML", "Numer rachunku odbiorcy");
            tdList.Add(elementMock.MockInstance);

            elementMock = AddElementMock(typeof(IHTMLElement));
            elementMock.ExpectAndReturn("get_innerHTML", enteredAccountNo);
            tdList.Add(elementMock.MockInstance);

            elementMock = AddElementMock(typeof(IHTMLElement));
            elementMock.ExpectAndReturn("get_innerHTML", "anything 2");
            elementMock.ExpectAndReturn("get_innerHTML", "anything 2");
            tdList.Add(elementMock.MockInstance);

            elementMock = AddElementMock(typeof(IHTMLElement));
            elementMock.ExpectAndReturn("get_innerHTML", "Kwota");
            tdList.Add(elementMock.MockInstance);

            elementMock = AddElementMock(typeof(IHTMLElement));
            elementMock.ExpectAndReturn("get_innerHTML", amountPaid + " PLN");
            elementMock.ExpectAndReturn("get_innerHTML", amountPaid + " PLN");
            tdList.Add(elementMock.MockInstance);

            elements.ExpectAndReturn("GetEnumerator", tdList.GetEnumerator());
        }
        private void AddDefinedTransferMock(ArrayList tdList, String className, bool repeatClass, bool transferNamesMatch)
        {
            DynamicMock td = AddElementMock(typeof(IHTMLElement));

            td.ExpectAndReturn("get_className", className);
            if (repeatClass == true)
            {
                td.ExpectAndReturn("get_className", className);
            }
            td.ExpectAndReturn("get_innerHTML", "&nbsp;" + paymentInfo.DefinedTransferName + "<BR>");
            tdList.Add(td.MockInstance);

            for (int i = 0; i < 3; i++)
            {
                td = AddElementMock(typeof(IHTMLElement));
                tdList.Add(td.MockInstance);
            }

            td = AddElementMock(typeof(IHTMLElement));
            td.ExpectAndReturn("get_innerHTML", "<TABLE><TR><TD>Something</TD></TR></TABLE>");

            if (transferNamesMatch == true)
            {
                DynamicMock table = AddElementMock(typeof(IHTMLElementCollection));
                td.ExpectAndReturn("get_all", table.MockInstance);

                ArrayList   tableList = new ArrayList();
                DynamicMock anchor    = AddElementMock(typeof(FakeHtmlAnchorElement));
                anchor.ExpectAndReturn("get_innerHTML", "Wykonaj");
                tableList.Add(anchor.MockInstance);

                anchor = AddElementMock(typeof(FakeHtmlAnchorElement));
                anchor.ExpectAndReturn("get_innerHTML", "Zap³aæ");
                anchor.Expect("click");
                tableList.Add(anchor.MockInstance);
                table.ExpectAndReturn("GetEnumerator", tableList.GetEnumerator());
            }
            tdList.Add(td.MockInstance);
        }
Beispiel #22
0
        public void ShouldCallFarmServiceAndIfSuccessfulShowSuccessMessage()
        {
            IResponse response = new HtmlFragmentResponse("foo");
            // Setup
            IProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject");

            cruiseRequestMock.ExpectAndReturn("ProjectSpecifier", projectSpecifier);
            requestMock.ExpectAndReturn("GetChecked", true, "PurgeWorkingDirectory");
            requestMock.ExpectAndReturn("GetChecked", false, "PurgeArtifactDirectory");
            requestMock.ExpectAndReturn("GetChecked", true, "PurgeSourceControlEnvironment");
            farmServiceMock.Expect("DeleteProject", projectSpecifier, true, false, true, null);
            string expectedMessage = "Project Deleted";

            viewBuilderMock.ExpectAndReturn("BuildView", response, new DeleteProjectModel(projectSpecifier, expectedMessage, false, true, false, true));

            // Execute
            IResponse returnedResponse = doDeleteProjectAction.Execute(cruiseRequest);

            // Verify
            Assert.AreEqual(response, returnedResponse);
            VerifyAll();
        }
        public void ShouldExecuteActionFromFactoryAndReturnHtml()
        {
            /// Setup
            mockActionFactory.ExpectAndReturn("Create", action, request);
            mockAction.ExpectAndReturn("Execute", response, request);
            mockFingerprintFactory.SetupResult("BuildFromRequest", ConditionalGetFingerprint.NOT_AVAILABLE, typeof(IRequest));

            /// Execute & Verify
            Assert.AreEqual(response, controller.Do());
            VerifyAll();
        }
        /// <param name="args">Additional (optional) arguments used for FakeHtmlSelectElement type:<br/>
        /// args[0] - repeat value in the Select element?<br/>
        /// args[1] - value in the Select will be selected?
        /// </param>
        private void PrepareInput(DynamicMock input, String value, Type type, params bool[] args)
        {
            if (type == typeof(FakeHtmlSelectElement))
            {
                DynamicMock options = AddElementMock(typeof(IHTMLElementCollection));
                input.ExpectAndReturn("get_all", options.MockInstance);

                ArrayList   optionsList = new ArrayList();
                DynamicMock option      = AddElementMock(typeof(FakeHtmlOptionElement));
                option.ExpectAndReturn("get_text", value + "123");
                optionsList.Add(option.MockInstance);

                option = AddElementMock(typeof(FakeHtmlOptionElement));
                option.ExpectAndReturn("get_text", "456" + value);
                optionsList.Add(option.MockInstance);

                option = AddElementMock(typeof(FakeHtmlOptionElement));
                option.ExpectAndReturn("get_text", value);
                optionsList.Add(option.MockInstance);

                if (args.Length > 0 && args[0] == true)
                {
                    option = AddElementMock(typeof(FakeHtmlOptionElement));
                    option.ExpectAndReturn("get_text", value);
                    optionsList.Add(option.MockInstance);
                }
                options.ExpectAndReturn("GetEnumerator", optionsList.GetEnumerator());

                // select this option?
                if (args.Length == 0 || (args.Length > 1 && args[1] == true))
                {
                    input.Expect("set_selectedIndex", 2);
                }
            }
            else
            {
                input.Expect("set_value", value);
            }
        }
        /// <summary>
        /// Updates the achievements.
        /// </summary>
        /// <param name="steamUserId">The steam user id.</param>
        private static void UpdateAchievements(string steamUserId)
        {
            DynamicMock      repositoryMock = new DynamicMock(typeof(ISteamRepository));
            ISteamRepository repository     = (ISteamRepository)repositoryMock.MockInstance;

            repositoryMock.ExpectAndReturn("get_Achivements", GetDataAchievements().AsQueryable());
            repositoryMock.ExpectAndReturn("get_Users",
                                           new List <Data.User>
            {
                new Data.User {
                    FacebookUserId = 0, SteamUserId = steamUserId
                }
            }.
                                           AsQueryable());
            repositoryMock.ExpectAndReturn("get_UserAchievements", new List <Data.UserAchievement>().AsQueryable());

            AchievementManager manager = new AchievementManager(repository);
            ICollection <Data.UserAchievement> achievements = GetCommunityAchievements(steamUserId);

            // should not throw InvalidOperationException
            manager.UpdateAchievements(achievements);
        }
Beispiel #26
0
        public void ShouldUseObjectGiverToInstantiateActions()
        {
            DynamicMock   objectSourceMock  = new DynamicMock(typeof(ObjectSource));
            Type          typeToInstantiate = typeof(XslReportBuildAction);
            ICruiseAction instantiated      = new XslReportBuildAction(null, null);

            objectSourceMock.ExpectAndReturn("GetByType", instantiated, typeToInstantiate);

            ActionInstantiatorWithObjectSource instantiator = new ActionInstantiatorWithObjectSource((ObjectSource)objectSourceMock.MockInstance);

            Assert.AreEqual(instantiated, instantiator.InstantiateAction(typeToInstantiate));
            objectSourceMock.Verify();
        }
Beispiel #27
0
        public void TestUpdateCity()
        {
            City city = new City {
                Name = "Pekin", DistrictId = 12
            };
            List <City> cities = new List <City> {
                city
            };

            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));

            mockLocationsManager.ExpectAndReturn("AddCity", 3, city);
            mockLocationsManager.SetReturnValue("GetCities", cities);
            mockLocationsManager.ExpectAndReturn("UpdateCity", true, city);


            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual("Pekin", locationService.GetCities()[0].Name);
            Assert.AreEqual(true, locationService.UpdateCity(city));
        }
Beispiel #28
0
        public void VerifyUserAgent(string expected)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var mock = new DynamicMock(typeof(IAndroidWrapper));
#pragma warning restore CS0618 // Type or member is obsolete
            mock.ExpectAndReturn("CallStatic", "1.0.0", "GetSdkVersion");
            Assert.AreEqual(
                string.Format(
                    CultureInfo.InvariantCulture,
                    expected,
                    FacebookSdkVersion.Build),
                Constants.GraphApiUserAgent);
        }
        public void ShouldDeleteClientSpecAndWorkingDirectoryOnPurge()
        {
            // Setup
            DynamicMock p4Mock = new DynamicMock(typeof(P4));
            P4          p4     = (P4)p4Mock.MockInstance;

            p4.Client = "myClient";

            ProcessInfo processInfo = new ProcessInfo("deleteclient");

            processInfoCreatorMock.ExpectAndReturn("CreateProcessInfo", processInfo, p4, "client -d myClient");
            processExecutorMock.ExpectAndReturn("Execute", new ProcessResult("", "", 0, false), processInfo);

            Assert.IsTrue(Directory.Exists(tempDirPath));

            // Execute
            p4Purger.Purge(p4, tempDirPath);

            // Verify
            Assert.IsFalse(Directory.Exists(tempDirPath));
            VerifyAll();
        }
        public void ReturnsServerLogFromRequestedServer()
        {
            // Setup
            requestMock.ExpectAndReturn("BuildSpecifier", buildSpecifier);
            buildRetrieverMock.ExpectAndReturn("GetBuild", build, buildSpecifier, null);
            urlBuilderMock.ExpectAndReturn("Extension", "foo");
            urlBuilderMock.Expect("Extension", "xml");
            urlBuilderMock.ExpectAndReturn("BuildBuildUrl", "myUrl", XmlBuildLogAction.ACTION_NAME, buildSpecifier);
            urlBuilderMock.Expect("Extension", "foo");

            Hashtable expectedContext = new Hashtable();

            expectedContext["log"]    = "some stuff in a log with a &lt; and &gt;";
            expectedContext["logUrl"] = "myUrl";

            velocityViewGeneratorMock.ExpectAndReturn("GenerateView", response, "BuildLog.vm", new HashtableConstraint(expectedContext));

            // Execute & Verify
            Assert.AreEqual(response, buildLogAction.Execute((ICruiseRequest)requestMock.MockInstance));

            VerifyAll();
        }
		public void CreateMockForMBRClass()
		{
			DynamicMock classMock = new DynamicMock( typeof( MBRClass ) );
			MBRClass classInstance = (MBRClass)classMock.MockInstance;
			classMock.Expect( "SomeMethod" );
			classMock.ExpectAndReturn( "AnotherMethod", "Hello World", 5, "hello" );
			classMock.ExpectAndReturn( "MethodWithParams", 42, new object[] { new string[] { "the", "answer" } } );
			classInstance.SomeMethod();
			Assert.AreEqual( "Hello World", classInstance.AnotherMethod( 5, "hello" ) );
			Assert.AreEqual( 42, classInstance.MethodWithParams( "the", "answer" ) );
			classMock.Verify();
		}