public void DrpAccount_SelectedIndexChanged_CreateCookie_Redirect() { // Arrange InitializeAuthTests(); var drpClient = new DropDownList(); drpClient.Items.Add("1"); drpClient.SelectedValue = "1"; _accountsHomePagePrivate.SetField("drpClient", drpClient); var drpclientgroup = new DropDownList { }; drpclientgroup.Items.Add("1"); drpclientgroup.SelectedValue = "1"; _accountsHomePagePrivate.SetField("drpclientgroup", drpclientgroup); ShimFormsAuthentication.SignOut = () => { }; ShimFormsAuthentication.SetAuthCookieStringBoolean = (p1, p2) => { }; ShimCustomer.GetByClientIDInt32Boolean = (p1, p2) => new Customer { }; var cookies = new HttpCookieCollection(); ShimHttpResponse.AllInstances.CookiesGet = (p) => cookies; ShimFormsAuthentication.EncryptFormsAuthenticationTicket = (p) => "test"; // Act _accountsHomePagePrivate.Invoke("drpAccount_SelectedIndexChanged", new object[] { null, null }); // Assert _accountsHomePagePrivate.ShouldSatisfyAllConditions( () => _redirectUrl.ShouldBe("~/Default.aspx"), () => cookies[FormsAuthentication.FormsCookieName].ShouldNotBeNull(), () => cookies[FormsAuthentication.FormsCookieName].Value.ShouldBe("test")); }
public void Setup() { _shimContext = ShimsContext.Create(); _communicatorInstance = new masterPage.Communicator(); _shimCommunicator = new ShimCommunicator(_communicatorInstance); _communicatorPrivateObject = new PrivateObject(_communicatorInstance); _drpClient = new DropDownList(); _communicatorPrivateObject.SetField("drpClient", _drpClient); _drpclientgroup = new DropDownList(); _drpclientgroup.Items.Add("5"); _drpclientgroup.SelectedValue = "1"; _communicatorPrivateObject.SetField("drpclientgroup", _drpclientgroup); }
public void OnTeamCollectionBookStatusChange_TeamCollection_GivenCheckedOutByOther_WhenCheckedOutByNone_RemovesIcon() { // Setup // var collectionFolder = new TemporaryFolder("LibraryListViewTests"); Book.BookCollectionTests.AddBook(collectionFolder, "book1"); _view = new LibraryListView(new FakeLibraryModel(collectionFolder), new BookSelection(), new SelectedTabChangedEvent(), new LocalizationChangedEvent(), new BookStatusChangeEvent(), null); var primaryCollectionFlow = new FlowLayoutPanel(); var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view); obj.SetField("_primaryCollectionFlow", primaryCollectionFlow); _view.LoadPrimaryCollectionButtons(); _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.Other)); var button = primaryCollectionFlow.Controls.OfType <Button>().First(); Assert.AreEqual(1, button.Controls.OfType <Label>().Count(), "Test was not set up properly. Wrong number of labels."); // System Under Test // _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.None)); // Verification // var labelOfButton = button.Controls.OfType <Label>().FirstOrDefault(); Assert.IsNull(labelOfButton); }
public void ProcessTaskTest_InputTaskRecord_IsTaskLocked() { IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task(); var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x); x.Initialise(new Host(), 0); TaskResponse resp = new TaskResponse(); privateObject.SetField("_Task", resp); privateObject.Invoke("ProcessTask"); }
public void GetTaskTest_InputTestMode1_ExpectTaskRecord() { WcfSelfHost host = new WcfSelfHost(typeof(Service)); IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task(); var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x); x.Initialise(new Host(), 0); privateObject.SetField("_TestMode", 1); bool ok = Convert.ToBoolean(privateObject.Invoke("GetTask")); Assert.IsFalse(ok); host.Dispose(); host = null; }
public void PostResultsTests_InputTestMode1_OutputSuccess() { WcfSelfHost host = new WcfSelfHost(typeof(Service)); IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task(); var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x); x.Initialise(new Host(), 0); PostResultsRequest req = new PostResultsRequest(); req.TestMode = 1; privateObject.SetField("_Results", req); privateObject.Invoke("PostResults"); //privateObject.Invoke("APrivateMethod", new object[] { param1, param2}); -- Call Private method with parameters host.Dispose(); host = null; }
public void OnTeamCollectionBookStatusChange_TeamCollection_CheckedOutBySelf() { // Setup // var collectionFolder = new TemporaryFolder("LibraryListViewTests"); Book.BookCollectionTests.AddBook(collectionFolder, "book1"); _view = new LibraryListView(new FakeLibraryModel(collectionFolder), new BookSelection(), new SelectedTabChangedEvent(), new LocalizationChangedEvent(), new BookStatusChangeEvent(), null); var primaryCollectionFlow = new FlowLayoutPanel(); var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view); obj.SetField("_primaryCollectionFlow", primaryCollectionFlow); _view.LoadPrimaryCollectionButtons(); // System Under Test // _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.Self)); // Verification // var button = primaryCollectionFlow.Controls.OfType <Button>().First(); var labelOfButton = button.Controls.OfType <Label>().First(); AssertImageCenterIsColor(labelOfButton.Image, Palette.BloomYellow); }
private void InitializeFields() { _accountsMasterPagePrivate.SetField(SiteMapSecnodLevelFieldName, _siteMapSecondLevelField); _accountsMasterPagePrivate.SetField("Menu", _menuField); }