public void DrpAccount_SelectedIndexChanged_CreateCookie_Redirect() { // Arrange InitializeAuthTests(); _drpClient.Items.Add("1"); _drpClient.SelectedValue = "1"; ShimFormsAuthentication.SignOut = () => { }; ShimFormsAuthentication.SetAuthCookieStringBoolean = (p1, p2) => { }; ShimCustomer.GetByClientIDInt32Boolean = (p1, p2) => new Customer { }; var cookies = new HttpCookieCollection(); ShimHttpResponse.AllInstances.CookiesGet = (p) => cookies; ShimFormsAuthentication.EncryptFormsAuthenticationTicket = (p) => p.UserData; // Act _communicatorPrivateObject.Invoke("drpAccount_SelectedIndexChanged", new object[] { null, null }); // Assert _communicatorPrivateObject.ShouldSatisfyAllConditions( () => _redirectUrl.ShouldBe("~/Default.aspx"), () => cookies[FormsAuthentication.FormsCookieName].ShouldNotBeNull(), () => cookies[FormsAuthentication.FormsCookieName].Value.ShouldBe("-1,,5,1,00000000-0000-0000-0000-000000000000")); }
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")); }
private void CallMenu_MenuItemDataBound(MenuItem menuItem) { const string MethodName = "Menu_MenuItemDataBound"; var eventArguments = new MenuEventArgs(menuItem); _accountsMasterPagePrivate.Invoke(MethodName, new object[] { null, eventArguments }); }
public void XXX_Ok() { var private_function = new PrivateFunction(); var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(private_function); Assert.True((bool)obj.Invoke("XXX")); }
public void TestMethod6() { var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(new Class1()); var actual = obj.Invoke("addAndZeroFormat", 10, 3) as string; Assert.Equal("0000013", actual); }
public void TestMethod5() { var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(new Class1()); var actual = obj.Invoke("getDisplayName") as string; Assert.Equal("ConsoleApp1.Class1: Hello", actual); }
public void XXXInit_Ok() { var studentRepositories = new StudentService(); var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(studentRepositories); Assert.True((bool)obj.Invoke("XXXInit")); }
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 BadCommandThrows() { Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(git); GitException ex = Assert.Throws <GitException>(() => { obj.Invoke("GitCommand", new object[] { "boogers" }); }); Assert.True(ex.Message.ToLower().Contains("not a git command")); }
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; }
internal static string CallParseIdentifierInternal(this Parser targetClass) { var po = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(targetClass); try { return((string)po.Invoke("ParseIdentifierInternal", new object[] { })); } catch (System.MissingMethodException missingMethodException) { throw new System.NotSupportedException("ParseIdentifierInternal with requested parameters is not found. Rerun code generation.", missingMethodException); } }
internal static int CallGetExpressionEnd(this Parser targetClass) { var po = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(targetClass); try { return((int)po.Invoke("GetExpressionEnd", new object[] { })); } catch (System.MissingMethodException missingMethodException) { throw new System.NotSupportedException("GetExpressionEnd with requested parameters is not found. Rerun code generation.", missingMethodException); } }
internal static void CallUpdateSchemas(this DifferenceCreator targetClass, Database database, StreamWriter writer, PgDatabase oldDatabase, PgDatabase newDatabase) { var po = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(targetClass); try { po.Invoke("UpdateSchemas", new object[] { database, writer, oldDatabase, newDatabase }); } catch (System.MissingMethodException missingMethodException) { throw new System.NotSupportedException("UpdateSchemas with requested parameters is not found. Rerun code generation.", missingMethodException); } }
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 PlayButton_DefaultMode_Started() { //Arrange Form1 form = new Form1(); form.UI = new UI(form); Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject pvt = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(form); Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject pvtUI = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(form.UI); Button buttonPlay = (Button)pvt.GetField("buttonPlay"); Label labelScore = (Label)pvtUI.GetField("labelScore"); //Act pvt.Invoke("buttonPlay_Click", new object[2] { this, new EventArgs() }); //Assert Assert.That(form.IsPlaying && labelScore.Text == "Score: 0"); }
public void LoadOneCollection_NonEditableCollection_BookNotSelected() { // Setup // var collectionFolder = new TemporaryFolder("LibraryListViewTests"); var collection = new BookCollection(collectionFolder.Path, BookCollection.CollectionType.SourceCollection, new BookSelection()); BloomTests.Book.BookCollectionTests.AddBook(collectionFolder, "book1"); BookSelection bookSelection = new BookSelection(); _view = new LibraryListView(new FakeLibraryModel(collectionFolder), bookSelection, new SelectedTabChangedEvent(), new LocalizationChangedEvent(), new BookStatusChangeEvent(), null); Bloom.Properties.Settings.Default.CurrentBookPath = Path.Combine(collectionFolder.Path, "book1"); // System Under Test // var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view); obj.Invoke("LoadOneCollection", collection, new System.Windows.Forms.FlowLayoutPanel()); // Verification // Assert.IsNull(bookSelection.CurrentSelection); }
private DataBasePurpose GetPurpose(string value) { return((DataBasePurpose)pObj.Invoke("GetPurpose", value)); }
private void CallbtnSave_Click() { const string MethodName = "btnSave_Click"; _baseChannelEditorPrivate.Invoke(MethodName, new object[] { null, null }); }