NSubstitute.Substitute.For(params object[])

Here are the examples of the csharp api NSubstitute.Substitute.For(params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

620 Examples 7

19 View Source File : Stub.cs
License : Apache License 2.0
Project Creator : 42skillz

public static IWebClient AWebClientWith(string showId, string layoutTheaterJsonFileName, string bookedSeatsJsonFileName)
        {
            var webClient = Subsreplacedute.For<IWebClient>();
            var jsonDirPath = Path.Combine(GetExecutingreplacedemblyDirectoryFullPath(), "AuditoriumLayouts");
            webClient.GetAsync(Arg.Is<string>(s => s.EndsWith($"/api/v1/data_for_auditoriumSeating/{showId}")))
                .Returns(new HttpResponseMessage {StatusCode = HttpStatusCode.OK, Content = new StringContent(File.ReadAllText($"{Path.Combine(jsonDirPath, layoutTheaterJsonFileName)}"))});

            webClient.GetAsync(Arg.Is<string>(s => s.EndsWith($"api/v1/data_for_reservation_seats/{showId}")))
                .Returns(new HttpResponseMessage {StatusCode = HttpStatusCode.OK, Content = new StringContent(File.ReadAllText($"{Path.Combine(jsonDirPath, bookedSeatsJsonFileName)}"))});

            return webClient;
        }

19 View Source File : TrainTrainSystemShould.cs
License : MIT License
Project Creator : 42skillz

private static IBookingReferenceService BuildBookingReferenceService(string bookingReference)
        {
            var bookingReferenceService = Subsreplacedute.For<IBookingReferenceService>();
            bookingReferenceService.GetBookingReference().Returns(Task.FromResult(bookingReference));
            return bookingReferenceService;
        }

19 View Source File : TrainTrainSystemShould.cs
License : MIT License
Project Creator : 42skillz

private static ITrainDataService BuildTrainDataService(string trainId, string trainTopology)
        {
            var trainDataService = Subsreplacedute.For<ITrainDataService>();
            trainDataService.GetTrain(trainId)
                .Returns(Task.FromResult(trainTopology));
            return trainDataService;
        }

19 View Source File : NumericPropertyTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(-32768)]
        [TestCase(0)]
        [TestCase(32767)]
        public void TryValidate_ShouldValidateShort(short value)
        {
            NumericProperty<short> sut = CreateSut<short>();

            sut.Value = value.ToString();

            replacedert.IsTrue(sut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : NumericPropertyTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(-32769)]
        [TestCase(32768)]
        public void TryValidate_ShouldNotValidateShort(int value)
        {
            NumericProperty<short> sut = CreateSut<short>();

            sut.Value = value.ToString();

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsFalse(sut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("'Num Prop' must be a valid Int16.");
        }

19 View Source File : NumericPropertyTest.cs
License : MIT License
Project Creator : alexleen

[TestCase((ushort)0)]
        [TestCase((ushort)65535)]
        public void TryValidate_ShouldValidateUShort(ushort value)
        {
            NumericProperty<ushort> sut = CreateSut<ushort>();

            sut.Value = value.ToString();

            replacedert.IsTrue(sut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : NumericPropertyTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(-1)]
        [TestCase(65536)]
        public void TryValidate_ShouldNotValidateUShort(int value)
        {
            NumericProperty<ushort> sut = CreateSut<ushort>();

            sut.Value = value.ToString();

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsFalse(sut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("'Num Prop' must be a valid UInt16.");
        }

19 View Source File : NumericPropertyTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(-2147483649)]
        [TestCase(2147483648)]
        public void TryValidate_ShouldNotValidateAnInt(long value)
        {
            NumericProperty<int> sut = CreateSut<int>();

            sut.Value = value.ToString();

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsFalse(sut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("'Num Prop' must be a valid Int32.");
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("")]
        [TestCase(null)]
        public void TryValidate_ShouldReturnTrue_WhenPatternIsNullOrEmpty_WhenNoneIsSelected(string pattern)
        {
            mSut.SelectedLayout = LayoutDescriptor.None;
            mSut.Pattern = pattern;

            replacedert.IsTrue(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : MaxSizeRollBackupsTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldSucceed_WhenInt()
        {
            mSut.Value = "1";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : RequiredStringPropertyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldReturnFalse_WhenValueNotSpecified()
        {
            replacedert.IsFalse(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : RequiredStringPropertyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldReturnTrue_WhenValueSpecified()
        {
            mSut.Value = "whatev";

            replacedert.IsTrue(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : RequiredStringPropertyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldShowError_WhenValueNotSpecified()
        {
            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            mSut.TryValidate(messageBoxService);

            messageBoxService.Received(1).ShowError(Arg.Is<string>(arg => arg == "'name' must be specified."));
        }

19 View Source File : StringMatchTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldCallValidate()
        {
            //Test sanity check
            replacedert.IsFalse(mValidateCalled);

            mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>());

            replacedert.IsTrue(mValidateCalled);
        }

19 View Source File : AspNetTraceAppenderTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetNode = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);

            IElementConfiguration configuration = Subsreplacedute.For<IElementConfiguration>();
            configuration.ConfigXml.Returns(xmlDoc);
            configuration.Log4NetNode.Returns(log4NetNode);

            mSut = new AspNetTraceAppender(configuration);
            mSut.Initialize();
        }

19 View Source File : AsyncAppenderTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetNode = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);

            IElementConfiguration configuration = Subsreplacedute.For<IElementConfiguration>();
            configuration.ConfigXml.Returns(xmlDoc);
            configuration.Log4NetNode.Returns(log4NetNode);

            mSut = new AsyncAppender(configuration);
        }

19 View Source File : BufferingForwardingAppenderTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetNode = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);

            IElementConfiguration configuration = Subsreplacedute.For<IElementConfiguration>();
            configuration.ConfigXml.Returns(xmlDoc);
            configuration.Log4NetNode.Returns(log4NetNode);

            mSut = new BufferingForwardingAppender(configuration);
            mSut.Initialize();
        }

19 View Source File : FileAppenderTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetNode = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);

            IElementConfiguration configuration = Subsreplacedute.For<IElementConfiguration>();
            configuration.ConfigXml.Returns(xmlDoc);
            configuration.Log4NetNode.Returns(log4NetNode);

            mSut = new FileAppender(configuration);
        }

19 View Source File : AppendReplaceSaveStrategyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Execute_ShouldAppend_WhenOriginalNodeIsNull()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetElement = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);
            XmlElement newElement = xmlDoc.CreateElement("appender");

            IElementConfiguration config = Subsreplacedute.For<IElementConfiguration>();
            config.Log4NetNode.Returns(log4NetElement);
            config.NewNode.Returns(newElement);

            ISaveStrategy strategy = new AppendReplaceSaveStrategy(config, false);
            strategy.Execute();

            replacedert.AreEqual(newElement, log4NetElement.FirstChild);
        }

19 View Source File : AppendReplaceSaveStrategyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Execute_ShouldReplace_WhenOriginalNodeIsNotNull()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetElement = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);
            XmlElement origElement = xmlDoc.CreateElement("origAppender");
            log4NetElement.AppendChild(origElement);
            XmlElement newElement = xmlDoc.CreateElement("newAppender");

            IElementConfiguration config = Subsreplacedute.For<IElementConfiguration>();
            config.Log4NetNode.Returns(log4NetElement);
            config.OriginalNode.Returns(origElement);
            config.NewNode.Returns(newElement);

            ISaveStrategy strategy = new AppendReplaceSaveStrategy(config, false);
            strategy.Execute();

            replacedert.AreEqual(1, log4NetElement.ChildNodes.Count);
            replacedert.AreEqual(newElement, log4NetElement.FirstChild);
        }

19 View Source File : AppendReplaceSaveStrategyTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void Execute_ShouldAppend_WhenOriginalNodeIsNotNull_AndForceAppendIsTrue()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            XmlElement log4NetElement = xmlDoc.CreateElement(Log4NetXmlConstants.Log4Net);
            XmlElement origElement = xmlDoc.CreateElement("origAppender");
            XmlElement newElement = xmlDoc.CreateElement("newAppender");

            IElementConfiguration config = Subsreplacedute.For<IElementConfiguration>();
            config.Log4NetNode.Returns(log4NetElement);
            config.OriginalNode.Returns(origElement);
            config.NewNode.Returns(newElement);

            //Sanity check
            replacedert.AreEqual(0, log4NetElement.ChildNodes.Count);

            ISaveStrategy strategy = new AppendReplaceSaveStrategy(config, true);
            strategy.Execute();

            replacedert.AreEqual(1, log4NetElement.ChildNodes.Count);
            replacedert.AreEqual(newElement, log4NetElement.FirstChild);
        }

19 View Source File : ConfigurationFactory.CanLoadAndSaveXmlTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            IConfigurationXml configFactory = new ConfigurationFactory(Subsreplacedute.For<IToastService>()).Create(Filename);

            const string sutFieldName = "LoadAndSave";

            mSut = (ICanLoadAndSaveXml)configFactory.GetType().GetField(sutFieldName, BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(configFactory);

            if (mSut == null)
            {
                replacedert.Fail($"Unable to find private instance field '{sutFieldName}'");
            }

            mXmlDoc = Subsreplacedute.For<IXmlDoreplacedent>();

            IXmlDoreplacedentFactory xmlDocFactory = Subsreplacedute.For<IXmlDoreplacedentFactory>();
            xmlDocFactory.Create().Returns(mXmlDoc);

            SetSutField("mXmlDocFactory", xmlDocFactory);

            IFile file = Subsreplacedute.For<IFile>();
            file.Exists(Filename).Returns(ci => mFileExists);

            SetSutField("mFile", file);

            mXmlWriterFactory = Subsreplacedute.For<IXmlWriterFactory>();
            SetSutField("mXmlWriterFactory", mXmlWriterFactory);

            //Subsreplacedute fileStreamFactory to avoid disk access attempts
            IFileStreamFactory fileStreamFactory = Subsreplacedute.For<IFileStreamFactory>();
            SetSutField("mFileStreamFactory", fileStreamFactory);
        }

19 View Source File : DatePatternTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(null)]
        [TestCase("")]
        public void TryValidate_ShouldShowMessageBoxAndReturnsFalse_WhenValueIsNullOrEmpty(string value)
        {
            mSut.Value = value;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsFalse(mSut.TryValidate(messageBoxService));

            messageBoxService.Received(1).ShowError("A valid date pattern must be replacedigned.");
        }

19 View Source File : DatePatternTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("HH:mm", ":")]
        [TestCase("HH<mm", "<")]
        [TestCase("HH>mm", ">")]
        [TestCase("HH\"mm", "\"")]
        [TestCase("HH/mm", "/")]
        [TestCase("HH\\mm", "\\")]
        [TestCase("HH|mm", "|")]
        [TestCase("HH?mm", "?")]
        [TestCase("HH*mm", "*")]
        //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 = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsFalse(mSut.TryValidate(messageBoxService));

            messageBoxService.Received(1).ShowError($"Date pattern must not contain invalid characters: '{invalidChar}'");
        }

19 View Source File : DatePatternTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowMessageBox_WhenValueIsNotNullOrEmpty()
        {
            mSut.Value = "yyyyMMdd";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            mSut.TryValidate(messageBoxService);

            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : DatePatternTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldReturnTrue_WhenValueIsNotNullOrEmpty()
        {
            mSut.Value = "yyyyMMdd";

            replacedert.IsTrue(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : FileTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mMessageBoxService = Subsreplacedute.For<IMessageBoxService>();

            mHistoryManager = Subsreplacedute.For<IHistoryManager>();
            mHistoricalFiles = new[] { "file1", "file2" };
            mHistoryManager.Get().Returns(mHistoricalFiles);

            IHistoryManagerFactory historyManagerFactory = Subsreplacedute.For<IHistoryManagerFactory>();
            historyManagerFactory.CreateFilePathHistoryManager().Returns(mHistoryManager);

            mSut = new File(mMessageBoxService, historyManagerFactory);
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mHistoryManager = Subsreplacedute.For<IHistoryManager>();
            mHistoryManagerFactory = Subsreplacedute.For<IHistoryManagerFactory>();
            mHistoryManagerFactory.CreatePatternsHistoryManager().Returns(mHistoryManager);
            mSut = new Layout(mHistoryManagerFactory);
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("")]
        [TestCase(null)]
        public void TryValidate_ShouldShowMessageBox_WhenPatternIsNullOrEmpty_WhenRequired(string pattern)
        {
            mSut.Pattern = pattern;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            mSut.TryValidate(messageBoxService);

            messageBoxService.Received(1).ShowError("A pattern must be replacedigned to this appender.");
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("")]
        [TestCase(null)]
        public void TryValidate_ShouldReturnFalse_WhenPatternIsNullOrEmpty_WhenRequired(string pattern)
        {
            mSut.Pattern = pattern;

            replacedert.IsFalse(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowMessageBox_WhenPatternIsNotNullOrEmpty()
        {
            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            mSut.TryValidate(messageBoxService);

            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : LayoutTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldReturnTrue_WhenPatternIsNotNullOrEmpty()
        {
            replacedert.IsTrue(mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : MappingTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mXmlDoc = new XmlDoreplacedent();
            mXmlDoc.LoadXml("<appender>\r\n" +
                            "<mapping>\r\n" +
                            " <level value=\"ERROR\" />\r\n" +
                            " <foreColor value=\"DarkRed\" />\r\n" +
                            " <backColor value=\"White\" />\r\n" +
                            "</mapping>\r\n" +
                            "<mapping>\r\n" +
                            " <level value=\"WARN\" />\r\n" +
                            " <foreColor value=\"Yellow\" />\r\n" +
                            "</mapping>\r\n" +
                            "<mapping>\r\n" +
                            " <level value=\"info\" />\r\n" +
                            " <backColor value=\"White\" />\r\n" +
                            "</mapping>\r\n" +
                            "<mapping>\r\n" +
                            " <level value=\"\" />\r\n" +
                            " <foreColor value=\"Blue\" />\r\n" +
                            "</mapping>\r\n" +
                            "</appender>");

            mMessageBoxService = Subsreplacedute.For<IMessageBoxService>();

            IConfiguration configuration = Subsreplacedute.For<IConfiguration>();
            configuration.ConfigXml.Returns(mXmlDoc);

            mSut = new Mapping(configuration, mMessageBoxService);
        }

19 View Source File : MaximumFileSizeTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("10KB")]
        [TestCase("10MB")]
        [TestCase("10GB")]
        public void TryValidate_ShouldSucceed(string value)
        {
            mSut.Value = value;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : MaximumFileSizeTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("10kb")]
        [TestCase("10")]
        [TestCase("10Gb")]
        public void TryValidate_ShouldFail(string value)
        {
            mSut.Value = value;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsFalse(mSut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("Maximum file size must end with either \"KB\", \"MB\", or \"GB\".");
        }

19 View Source File : MaxSizeRollBackupsTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotSucceed_WhenNotInt()
        {
            mSut.Value = "str";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsFalse(mSut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("Max size roll backups must be a valid integer.");
        }

19 View Source File : StringMatchFilterTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mSut = new StringMatchFilter();
            mMessageBoxService = Subsreplacedute.For<IMessageBoxService>();
            mSut.MessageBoxService = mMessageBoxService;
        }

19 View Source File : FileTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldSucceed_WhenFilePathIsSpecified()
        {
            mSut.FilePath = "filepath";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mXmlDoc = new XmlDoreplacedent();
            mLog4NetNode = mXmlDoc.CreateElement("log4net");
            mOriginalAppender = mXmlDoc.CreateElementWithAttribute("appender", "name", OriginalName);
            mOriginalAppender.AppendTo(mLog4NetNode);

            mAppenderConfiguration = Subsreplacedute.For<IElementConfiguration>();
            mAppenderConfiguration.ConfigXml.Returns(mXmlDoc);
            mAppenderConfiguration.Log4NetNode.Returns(mLog4NetNode);
            mAppenderConfiguration.OriginalNode.Returns(mOriginalAppender);

            mSut = new Name(mAppenderConfiguration);
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[TestCase("")]
        [TestCase(null)]
        public void TryValidate_ShouldShowUnreplacedignedMessageBox_WhenValueIsNullOrEmpty_AndReturnFalse(string value)
        {
            mSut.Value = value;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsFalse(mSut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("A name must be replacedigned to this appender.");
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowCollisionMessageBox_WhenAppenderNameCollides_ButIsSameAppender()
        {
            mSut.Load(mOriginalAppender);

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowCollisionMessageBox_WhenNoAppenderNamesCollide()
        {
            mSut.Value = OriginalName;
            mXmlDoc.CreateElementWithAttribute("appender", "name", "otherName").AppendTo(mLog4NetNode);

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowCollisionMessageBox_WhenOtherAppenderHasNoName()
        {
            mSut.Value = "appName";
            mXmlDoc.CreateElement("appender").AppendTo(mLog4NetNode);

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotShowUnreplacedignedMessageBox_WhenValueIsNotNullOrEmpty_AndReturnTrue()
        {
            mSut.Value = "name";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsTrue(mSut.TryValidate(messageBoxService));
            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

19 View Source File : NameTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldShowCollisionMessageBox_WhenAppenderNameCollides()
        {
            mSut.Value = OriginalName;
            mXmlDoc.CreateElementWithAttribute("appender", "name", mSut.Value).AppendTo(mLog4NetNode);

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();

            replacedert.IsFalse(mSut.TryValidate(messageBoxService));
            messageBoxService.Received(1).ShowError("Name must be unique.");
        }

19 View Source File : OutgoingRefsTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mXmlDoc = new XmlDoreplacedent();
            mXmlDoc.LoadXml("<log4net>\n" +
                            $"  <appender name=\"appender0\" type=\"{AppenderDescriptor.Console.TypeNamespace}\">\n" +
                            "    <appender-ref ref=\"appender1\" />\n" +
                            "    <appender-ref ref=\"appender2\" />\n" +
                            "  </appender>\n" +
                            $"  <appender name=\"appender1\" type=\"{AppenderDescriptor.Console.TypeNamespace}\">\n" +
                            "    <appender-ref ref=\"appender2\" />\n" +
                            "  </appender>\n" +
                            $"  <appender name=\"appender2\" type=\"{AppenderDescriptor.Console.TypeNamespace}\">\n" +
                            "  </appender>\n" +
                            $"  <appender name=\"appender3\" type=\"{AppenderDescriptor.Console.TypeNamespace}\">\n" +
                            "  </appender>\n" +
                            $"  <appender name=\"asyncAppender\" type=\"{AppenderDescriptor.Async.TypeNamespace}\">\n" +
                            "  </appender>\n" +
                            "  <root>\n" +
                            "  </root>\n" +
                            "</log4net>");

            IElementConfiguration appenderConfiguration = Subsreplacedute.For<IElementConfiguration>();
            appenderConfiguration.ConfigXml.Returns(mXmlDoc);
            appenderConfiguration.Log4NetNode.Returns(mXmlDoc.FirstChild);
            appenderConfiguration.OriginalNode.Returns(mXmlDoc.FirstChild["appender"]);

            mSut = new OutgoingRefs(appenderConfiguration);
        }

19 View Source File : ParamsTest.cs
License : MIT License
Project Creator : alexleen

[SetUp]
        public void SetUp()
        {
            mMessageBoxService = Subsreplacedute.For<IMessageBoxService>();
            IConfiguration configuration = Subsreplacedute.For<IConfiguration>();
            configuration.ConfigXml.Returns(new XmlDoreplacedent());

            mSut = new Params(configuration, mMessageBoxService);
        }

19 View Source File : RemoteAddressTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(null, false)]
        [TestCase("", false)]
        [TestCase("str", false)]
        [TestCase("-1", false)]
        [TestCase("65536", true)]
        [TestCase("1234", true)]
        [TestCase("1.2.3.4", true)]
        [TestCase("-1.2.3.4", false)]
        [TestCase("256.256.256.256", false)]
        public void TryValidate_ShouldReturnCorrectValue(string value, bool expectedResult)
        {
            mSut.Value = value;

            replacedert.AreEqual(expectedResult, mSut.TryValidate(Subsreplacedute.For<IMessageBoxService>()));
        }

19 View Source File : RemoteAddressTest.cs
License : MIT License
Project Creator : alexleen

[TestCase(null)]
        [TestCase("")]
        [TestCase("str")]
        [TestCase("-1")]
        [TestCase("-1.2.3.4")]
        [TestCase("256.256.256.256")]
        public void TryValidate_ShouldCallShowError(string value)
        {
            mSut.Value = value;

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            mSut.TryValidate(messageBoxService);

            messageBoxService.Received(1).ShowError("Remote address must be a valid IP address.");
        }

19 View Source File : RemoteAddressTest.cs
License : MIT License
Project Creator : alexleen

[Test]
        public void TryValidate_ShouldNotCallShowError()
        {
            mSut.Value = "1.2.3.4";

            IMessageBoxService messageBoxService = Subsreplacedute.For<IMessageBoxService>();
            mSut.TryValidate(messageBoxService);

            messageBoxService.DidNotReceive().ShowError(Arg.Any<string>());
        }

See More Examples