public void Ctor() { var viewMock = Mock.Create<CalendarDetailsView>(Constructor.Mocked); Mock.Arrange(() => viewMock.InitializeComponent()).IgnoreInstance().DoNothing(); var view = new CalendarDetailsView(); Assert.IsNotNull(view); }
public void InitializeComponent() { // arrange Mock.SetupStatic(typeof(Application)); // act var view = new CalendarDetailsView(); // assert Assert.IsNotNull(view); new PrivateAccessor(view).SetField("_contentLoaded", true); try { // act view.InitializeComponent(); } catch (Exception ex) { // assert Assert.Fail("Expected no exception, but got: " + ex.Message); } }
public void Test() { // arrange Mock.SetupStatic(typeof(Application)); var view = new CalendarDetailsView(); var textBox = Mock.Create<TextBox>(Behavior.CallOriginal); Mock.Arrange(() => textBox.Focus()).MustBeCalled(); var privateAccessor = new PrivateAccessor(view); // act privateAccessor.CallMethod("FocusTextBoxOnLoad", new object[] { textBox, null }); // assert Mock.Assert(textBox); // arrange Mock.Reset(); textBox.Text = "Holydays"; privateAccessor.CallMethod("FocusTextBoxOnLoad", new object[] { textBox, null }); // assert Mock.Assert(() => textBox.Focus(), Occurs.Never()); }