public void TestValidateArrangeWithInvalidName() { // Arrange var header = new Header { Name = "Arrange", Depth = 0, From = 1, To = 2, Children = new List <Header> { new Header { Name = "XXXX", Depth = 1, From = 1, To = 1, Children = new List <Header> { new Header { Depth = 2, From = 0, To = 0, Name = "BaseUri" } } }, new Header { Name = "HttpRequest Actual", Depth = 1, From = 2, To = 2, Children = new List <Header> { new Header { Depth = 2, From = 2, To = 2, Name = "BaseUri" } } } }, }; // Act HeaderValidator.ValidateArrange(header); }
public void TestValidate() { // Arrange var header = new Header { Name = "Root", Depth = -1, From = 0, To = 1, Children = new List <Header> { new Header { Name = "Arrange", Depth = 0, From = 0, To = 0, Children = new List <Header> { new Header { Name = "HttpRequest Actual", Depth = 1, From = 0, To = 0, Children = new List <Header> { new Header { Depth = 2, From = 0, To = 0, Name = "BaseUri" } } } } }, new Header { Name = "Assertion", Depth = 0, From = 1, To = 1, Children = new List <Header> { new Header { Name = "Uri", Depth = 1, From = 1, To = 1, } } } } }; // Act HeaderValidator.Validate(header); }
public void TestValidateHttpRequestWithBaseUriHavingChildren() { // Arrange var header = new Header { Name = "HttpRequest Expected", Children = new List <Header> { new Header { Name = "BaseUri", Children = new List <Header> { new Header { Name = "User-Agent" } } } } }; // Act HeaderValidator.ValidateHttpRequest(header); }
private IBlockValidator CreateBlockValidator(HeaderValidator headerValidator) => new BlockValidator( new TxValidator(SpecProvider.ChainId), headerValidator, new OmmersValidator(BlockTree, headerValidator, LogManager), SpecProvider, LogManager);
public void TestValidateHttpRequestWithFragmentHavingTwoChildren() { // Arrange var header = new Header { Name = "HttpRequest Expected", Children = new List <Header> { new Header { Name = "BaseUri", }, new Header { Name = "Fragment", Children = new List <Header> { new Header(), new Header(), } } } }; // Act HeaderValidator.ValidateHttpRequest(header); }
/// <summary> /// Parses csv to TestCases /// </summary> /// <param name="data">data parameter</param> /// <param name="resources">resources parameter</param> /// <returns>TestCase list</returns> public static TestCases Parse(List <List <string> > data, ResourceManager resources = null) { if (data == null || !data.Any()) { throw new ArgumentNullException("data"); } var rootHeader = HeaderParser.Parse(data); HeaderValidator.Validate(rootHeader); var cases = new TestCases(); var lastStartIndex = 0; for (var i = HeaderParser.HeaderRowCount; i < data.Count; i++) { var row = data[i]; if (!string.IsNullOrWhiteSpace(row[0])) { if (i != HeaderParser.HeaderRowCount) { cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, i - lastStartIndex), resources)); } lastStartIndex = i; } } cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, data.Count - lastStartIndex), resources)); return(cases); }
protected override void RunJournalCommand() { if (!string.IsNullOrWhiteSpace(Header)) { HeaderValidator.ValidateOrThrow(Header); } if (!string.IsNullOrWhiteSpace(Header) && (Body == null || !Body.Any())) { throw new PSArgumentException("Header cannot be used without Body. Please specify a Body and try again."); } var entryDate = LocalDate.FromDateTime(Date).PlusDays(DateOffset); var hour = Now.Time().Hour; if (hour >= 0 && hour <= 4) { var dayPrior = entryDate.Minus(Period.FromDays(1)); var question = $"Edit entry for '{dayPrior}' or '{entryDate}'?"; var result = Choice("It's after midnight!", question, 0, dayPrior.DayOfWeek.ToChoiceString(), entryDate.DayOfWeek.ToChoiceString()); if (result == 0) { entryDate = dayPrior; } } Commit(GitCommitType.PreAppendJournalEntry); var journal = OpenJournal(); journal.AppendEntryContent(entryDate, Body, Header, Tags); Commit(GitCommitType.PostAppendJournalEntry); }
public void TestValidateDepthFromToWithInvalidTo() { // Arrange var header = new Header { Name = "Parent", Depth = -1, From = 0, To = 4, Children = new List <Header> { new Header { Name = "Child", Depth = 0, From = 0, To = 2, }, new Header { Name = "Child", Depth = 0, From = 2, To = 5, } } }; // Act HeaderValidator.ValidateDepthFromTo(header, -1); }
public void TestValidateContentsWithHavingInvalidChildren() { // Arrange var header = new Header { Name = "Contents", Children = new List <Header> { new Header { Name = "Name", }, new Header { Name = "Expected", Children = new List <Header> { new Header { Name = "Value", }, } }, new Header { Name = "Actual", Children = new List <Header> { new Header { Name = "Query", }, } }, new Header { Name = "AAA", } } }; // Act HeaderValidator.ValidateContents(header); }
public void SetUp() { _blockchainProcessingQueue = Substitute.For <IBlockProcessingQueue>(); _blockchainProcessor = Substitute.For <IBlockchainProcessor>(); _blockTree = Build.A.BlockTree().OfChainLength(10).TestObject; HeaderValidator headerValidator = new HeaderValidator(_blockTree, NullSealEngine.Instance, MainnetSpecProvider.Instance, LimboLogs.Instance); _validator = new BlockValidator(Always.Valid, headerValidator, Always.Valid, MainnetSpecProvider.Instance, LimboLogs.Instance); }
public void Test() { IBlockTree blockchain = Substitute.For <IBlockTree>(); HeaderValidator headerValidator = new HeaderValidator(blockchain, NullSealEngine.Instance, null, null); OmmersValidator ommersValidator = new OmmersValidator(blockchain, headerValidator, null); TxValidator txValidator = new TxValidator(ChainId.MainNet); BlockValidator blockValidator = new BlockValidator(txValidator, headerValidator, ommersValidator, RopstenSpecProvider.Instance, null); }
public void TestValidateNotHavingChildrenWithEmptyChildren() { // Arrange var header = new Header { Name = "Parent", Depth = -1, From = 0, To = 4, Children = new List <Header>() }; // Act HeaderValidator.ValidateNotHavingChildren(header); }
public void Test() { IBlockTree blockchain = Substitute.For <IBlockTree>(); HeaderValidator headerValidator = new HeaderValidator(new DifficultyCalculator(RopstenSpecProvider.Instance), blockchain, NullSealEngine.Instance, null, null); OmmersValidator ommersValidator = new OmmersValidator(blockchain, headerValidator, null); SignatureValidator signatureValidator = new SignatureValidator(ChainId.MainNet); TransactionValidator transactionValidator = new TransactionValidator(signatureValidator); BlockValidator blockValidator = new BlockValidator(transactionValidator, headerValidator, ommersValidator, RopstenSpecProvider.Instance, null); }
public void TestValidateHavingChildrenWithNullChildren() { // Arrange var header = new Header { Name = "Parent", Depth = -1, From = 0, To = 4, Children = null }; // Act HeaderValidator.ValidateHavingChildren(header); }
public void TestValidateHttpRequestWithInvalidName() { // Arrange var header = new Header { Name = "HttpRequest aa", }; // Act HeaderValidator.ValidateHttpRequest(header); }
public void TestValidateWithInvalidName() { // Arrange var header = new Header { Name = "AA", }; // Act HeaderValidator.Validate(header); }
public void TestValidateContentsWithNotHavingChildren() { // Arrange var header = new Header { Name = "Contents", }; // Act HeaderValidator.ValidateContents(header); }
public void TestValidateAssertionWithNotHavingChildren() { // Arrange var header = new Header { Name = "Assertion", }; // Act HeaderValidator.ValidateAssertion(header); }
public void TestValidateContentsItemWithNotHavingChildren() { // Arrange var header = new Header { Name = "Expected" }; // Act HeaderValidator.ValidateContentsItem(header); }
public void TestValidateHttpRequestWithNotHavingChildren() { // Arrange var header = new Header { Name = "HttpRequest Expected", }; // Act HeaderValidator.ValidateHttpRequest(header); }
public void Should_True_HeaderValidation(string headerString, string expected) { // Arrange var validator = new HeaderValidator(); // Act var result = validator.DoValidate(headerString); // Asserts result.Should().Be(expected); }
public void TestValidateContentsWithHavingEmptyChildren() { // Arrange var header = new Header { Name = "Contents", Children = new List <Header>(), }; // Act HeaderValidator.ValidateContents(header); }
public void TestValidateHavingChildrenWithInvalidChildCount() { // Arrange var header = new Header { Name = "Parent", Depth = -1, From = 0, To = 4, Children = new List <Header> { new Header(), } }; // Act HeaderValidator.ValidateHavingChildren(header, 2); }
public void TestValidateDepthFromToWithInvalidFromTo() { // Arrange var header = new Header { Name = "Parent", From = 1, To = 0, }; // Act HeaderValidator.ValidateDepthFromTo(header, 1); }
public void TestValidateNotHavingGrandChildren() { // Arrange var header = new Header { Depth = 2, From = 5, To = 5, Name = "Headers", Children = new List <Header> { new Header { Depth = 3, From = 5, To = 5, Name = "Cache" } } }; // Act HeaderValidator.ValidateNotHavingGrandChildren(header); }
public void TestValidateHttpRequest() { // Arrange var header = new Header { Name = "HttpRequest Actual", Depth = 1, From = 1, To = 7, Children = new List <Header> { new Header { Depth = 2, From = 1, To = 1, Name = "BaseUri" }, new Header { Depth = 2, From = 2, To = 2, Name = "UserAgent" }, new Header { Depth = 2, From = 3, To = 3, Name = "PathInfos" }, new Header { Depth = 2, From = 4, To = 4, Name = "Fragment" }, new Header { Depth = 2, From = 5, To = 5, Name = "Headers", Children = new List <Header> { new Header { Depth = 3, From = 5, To = 5, Name = "Cache" } } }, new Header { Depth = 2, From = 6, To = 6, Name = "Cookies", Children = new List <Header> { new Header { Depth = 3, From = 6, To = 6, Name = "TestCookie" } } }, new Header { Depth = 2, From = 7, To = 7, Name = "QueryStrings", Children = new List <Header> { new Header { Depth = 3, From = 7, To = 7, Name = "TestQuery" } } }, }, }; // Act HeaderValidator.ValidateHavingChildren(header); }
private IBlockValidator CreateBlockValidator() { IBlockCacheService blockCacheService = new BlockCacheService(); PoSSwitcher = new PoSSwitcher(MergeConfig, SyncConfig.Default, new MemDb(), BlockTree, SpecProvider, LogManager); SealValidator = new MergeSealValidator(PoSSwitcher, Always.Valid); HeaderValidator preMergeHeaderValidator = new HeaderValidator(BlockTree, SealValidator, SpecProvider, LogManager); HeaderValidator = new MergeHeaderValidator(PoSSwitcher, preMergeHeaderValidator, BlockTree, SpecProvider, SealValidator, LogManager); return(new BlockValidator( new TxValidator(SpecProvider.ChainId), HeaderValidator, Always.Valid, SpecProvider, LogManager)); }
public void TestValidateWithInvalidNumberOfChildren() { // Arrange var header = new Header { Name = "Root", Children = new List <Header> { new Header(), new Header(), new Header(), } }; // Act HeaderValidator.Validate(header); }
public void TestValidateContentsWithExpectedNotHavingChildren() { // Arrange var header = new Header { Name = "Contents", Children = new List <Header> { new Header { Name = "Expected" } } }; // Act HeaderValidator.ValidateContents(header); }
public void TestValidateContentsItemWithHavingInvalidChildren() { // Arrange var header = new Header { Name = "Expected", Children = new List <Header> { new Header { Name = "AAA" } } }; // Act HeaderValidator.ValidateContentsItem(header); }