public void AddFilter_ShouldShowElementWindow(string filterType) { FilterDescriptor.TryFindByTypeNamespace(filterType, out FilterDescriptor descriptor); mSut.AddFilter.Execute(descriptor); mMessageBoxService.Received(1).ShowWindow(Arg.Any <ElementWindow>()); }
public void LoginCommandExecuted_ModelLoginReturnsFalse_MessageServiceShowErrorCalled() { _model.Login("", "").ReturnsForAnyArgs(false); _uut.LoginCommand.Execute(null); _messageService.Received().ShowError("Wrong username or password"); }
public void LoginCommandExecuted_CollectorDoesUserExistReturnsFalse_MessageServiceShowErrorCalled() { _collector.DoesUserExist("", "").ReturnsForAnyArgs(false); _sut.UserName = "******"; _sut.Password = "******"; _sut.LoginCommand.Execute(null); _messageService.Received().ShowError("Wrong username or password"); }
public void TryValidate_ShouldNotSucceed_WhenFilePathIsNotSpecified() { IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("A file must be assigned to this appender."); }
public void TryValidate_ShouldShowError_WhenValueNotSpecified() { IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); mSut.TryValidate(messageBoxService); messageBoxService.Received(1).ShowError(Arg.Is <string>(arg => arg == "'name' must be specified.")); }
public void TryValidate_ShouldShowMessageBox_WhenValueIsNullOrEmpty() { IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); mSut.TryValidate(messageBoxService); messageBoxService.Received(1).ShowError("A log name must be assigned to this appender."); }
public void TryValidate_ShouldFail_WhenValueIsNullOrEmpty(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("'Key' must be specified."); }
public void TryValidate_ShouldNotSucceed_WhenNotInt() { mSut.Value = "str"; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("Max size roll backups must be a valid integer."); }
public void TryValidate_ShouldFail(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("Maximum file size must end with either \"KB\", \"MB\", or \"GB\"."); }
public void TryValidate_ShouldShowUnassignedMessageBox_WhenValueIsNullOrEmpty_AndReturnFalse(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("A name must be assigned to this appender."); }
//There's a lot more here, but these are the most common //See https://stackoverflow.com/a/62888/7355697 public void TryValidate_ShouldShowMessageBoxAndReturnsFalse_WhenValueHasInvalidPathChars(string value, string invalidChar) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError($"Date pattern must not contain invalid characters: '{invalidChar}'"); }
public void TryValidate_ShouldShowMessageBoxAndReturnsFalse_WhenValueIsNullOrEmpty(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("A valid date pattern must be assigned."); }
public void TryValidate_ShouldShowCollisionMessageBox_WhenAppenderNameCollides() { mSut.Value = OriginalName; mXmlDoc.CreateElementWithAttribute("appender", "name", mSut.Value).AppendTo(mLog4NetNode); IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("Name must be unique."); }
public void TestEditor_ClickingCancelWhenChangesExist_PromptsUserToConfirm() { _messageBox.Show(Arg.Any <string>(), Arg.Any <string>(), MessageBoxButtons.YesNo) .Returns(DialogResult.No); _view.SaveEnabled.Returns(true); _view.OnFormIsClosing += Raise.Event <FormClosingEventHandler>(null, new FormClosingEventArgs(CloseReason.UserClosing, false)); _messageBox.Received(1).Show(Arg.Any <string>(), Arg.Any <string>(), MessageBoxButtons.YesNo); }
[TestCase("65536")] //Too big public void TryValidate_ShouldCallShowError(string value) { Sut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Sut.TryValidate(messageBoxService); messageBoxService.Received(1).ShowError($"Port must be a valid integer between {IPEndPoint.MinPort} and {IPEndPoint.MaxPort}."); }
public void TryValidate_ShouldCallShowError(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); mSut.TryValidate(messageBoxService); messageBoxService.Received(1).ShowError("Remote address must be a valid IP address."); }
public void TryValidate_ShouldShowMessageBox_WhenPatternIsNullOrEmpty_WhenRequired(string pattern) { mSut.Pattern = pattern; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); mSut.TryValidate(messageBoxService); messageBoxService.Received(1).ShowError("A pattern must be assigned to this appender."); }
public void ReportView_OnLoad_ControlsShowDefaultStates(string url) { int okDialogCalls = string.IsNullOrEmpty(url) ? 1 : 0; _presenter.Url = url; _presenter.ShowView(); _mockView.BackButtonEnabled.Should().BeFalse(); _mockView.ForwardButtonEnabled.Should().BeFalse(); _mockOKDialog.Received(okDialogCalls).Show(Arg.Any <string>(), Arg.Any <string>(), MessageBoxButtons.OK); }
public void TryValidate_ShouldShowMessageBoxAndReturnsFalse_WhenValueIsNotAnInt(string value) { mSut.Value = value; IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(mSut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("Buffer size must be a valid integer."); }
public void TryValidate_ShouldNotValidateAnInt(long value) { NumericProperty <int> sut = CreateSut <int>(); sut.Value = value.ToString(); IMessageBoxService messageBoxService = Substitute.For <IMessageBoxService>(); Assert.IsFalse(sut.TryValidate(messageBoxService)); messageBoxService.Received(1).ShowError("'Num Prop' must be a valid Int32."); }
public void Sut_ShouldCoordinateValidation(string strMatch, string regexMatchStr, int expectedMessageBoxCalls) { mSut.Initialize(); StringMatch stringMatch = (StringMatch)mSut.Properties.Single(p => p.GetType() == typeof(StringMatch)); RegexMatch regexMatch = (RegexMatch)mSut.Properties.Single(p => p.GetType() == typeof(RegexMatch)); stringMatch.Value = strMatch; regexMatch.Value = regexMatchStr; stringMatch.TryValidate(mMessageBoxService); mMessageBoxService.Received(expectedMessageBoxCalls).ShowError("Either 'String to Match' or 'Regex to Match' must be specified."); }
public void Add_ShouldShowParamElementWindow() { mSut.Add.Execute(null); mMessageBoxService.Received(1).ShowWindow(Arg.Any <ElementWindow>()); }
public void Open_ShouldShowOpenFilDialog() { mSut.Open.Execute(null); mMessageBoxService.Received(1).ShowOpenFileDialog(out string _); }