public void InvalidTemplate_SameParameterTwiceThrows() { ExceptionAssert.Throws <ArgumentException>( () => TemplateParser.Parse("{aaa}/{AAA}"), "The route parameter name 'AAA' appears more than one time in the route template. (Parameter 'routeTemplate')"); }
public void UnclosedIndexer() { ExceptionAssert.Throws <JsonException>(() => { new JPath("Blah[0"); }, @"Path ended with open indexer."); }
public void IndexerCloseInProperty() { ExceptionAssert.Throws <JsonException>(() => { new JPath("]"); }, "Unexpected character while parsing path: ]"); }
public void NoAtAfterOr() { ExceptionAssert.Throws <JsonException>(() => new JPath("[?(@.name||s"), "Unexpected character while parsing path query: s"); }
public void NoPathAfterDot2() { ExceptionAssert.Throws <JsonException>(() => new JPath("[?(@.name||@.)]"), @"Unexpected end while parsing path."); }
public void RootWithBadWhitespace2() { ExceptionAssert.Throws <JsonException>(() => { new JPath("$. Blah"); }, @"Unexpected character while parsing path: "); }
public void BaddOr3() { ExceptionAssert.Throws <JsonException>(() => new JPath("[?(@.name|"), "Unexpected character while parsing path query: |"); }
public void TestWinsorizedMeanOfNullCollectionThrowsArgumentNullException() { ExceptionAssert.Throws <ArgumentNullException>( CalculateWinsorizedMeanOfNullCollection); }
public void TestWinsorizedMeanOfEmptyCollectionThrowsInvalidOperationException() { ExceptionAssert.Throws <InvalidOperationException>( CalculateWinsorizedMeanOfEmptyCollection); }
public void DeserializeUnexpectedEnd() { ExceptionAssert.Throws <JsonSerializationException>(() => JsonConvert.DeserializeObject <KeyValuePair <string, int> >(@"{""Key"": ""123"","), "Unexpected end when reading KeyValuePair. Path 'Key', line 1, position 14."); }
public void DeserializeInvalidDataTable() { ExceptionAssert.Throws <JsonException>(() => JsonConvert.DeserializeObject <DataSet>("{\"pending_count\":23,\"completed_count\":45}"), "Unexpected JSON token when reading DataTable. Expected StartArray, got Integer. Path 'pending_count', line 1, position 19."); }
public void InvalidTemplate_CatchAllMarkedOptional() { ExceptionAssert.Throws <ArgumentException>( () => TemplateParser.Parse("{a}/{*b?}"), "A catch-all parameter cannot be marked optional. (Parameter 'routeTemplate')"); }
public void InvalidTemplate_CannotContainQuestionMark() { ExceptionAssert.Throws <ArgumentException>( () => TemplateParser.Parse("foor?bar"), "The literal section 'foor?bar' is invalid. Literal sections cannot contain the '?' character. (Parameter 'routeTemplate')"); }
public void InvalidTemplate_CannotStartWithTilde() { ExceptionAssert.Throws <ArgumentException>( () => TemplateParser.Parse("~foo"), "The route template cannot start with a '~' character unless followed by a '/'. (Parameter 'routeTemplate')"); }
public void InvalidTemplate_CatchAllMarkedOptional() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("{a}/{*b?}"), "A catch-all parameter cannot be marked optional."); }
public void InvalidTemplate_WithRepeatedParameter() { var ex = ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("{Controller}.mvc/{id}/{controller}"), "The route parameter name 'controller' appears more than one time in the route template."); }
public void NoFieldNameAfterDot() { ExceptionAssert.Throws <JsonException>(() => { new JPath("$.Blah."); }, @"Unexpected end while parsing path."); }
public void InvalidTemplate_CannotHaveMoreThanOneCatchAll() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("{*p1}/{*p2}"), "A catch-all parameter can only appear as the last segment of the route template."); }
public void SinglePropertyAndFilterWithUnknownEscape() { ExceptionAssert.Throws <JsonException>(() => { new JPath(@"Blah[ ?( @.name=='h\i' ) ]"); }, @"Unknown escape chracter: \i"); }
public void InvalidTemplate_SameParameterTwiceAndOneCatchAllThrows() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("{aaa}/{*AAA}"), "The route parameter name 'AAA' appears more than one time in the route template."); }
public void BaddOr4() { ExceptionAssert.Throws <JsonException>(() => new JPath("[?(@.name||"), "Path ended with open query."); }
public void InvalidTemplate_InvalidParameterNameWithOpenBracketThrows() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("{a}/{a{aa}/{z}"), "In a route parameter, '{' and '}' must be escaped with '{{' and '}}'."); }
public void NoPathAfterAt() { ExceptionAssert.Throws <JsonException>(() => new JPath("[?(@.name||@"), @"Path ended with open query."); }
public void InvalidTemplate_WithCatchAllNotAtTheEndThrows() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("foo/{p1}/{*p2}/{p3}"), "A catch-all parameter can only appear as the last segment of the route template."); }
public void BadCharactersInIndexer() { ExceptionAssert.Throws <JsonException>(() => { new JPath("Blah[[0]].Two.Three[1].Four"); }, @"Unexpected character while parsing path indexer: ["); }
public void InvalidTemplate_CannotStartWithTilde() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("~foo"), "The route template cannot start with a '~' character unless followed by a '/'."); }
public void EmptyIndexer() { ExceptionAssert.Throws <JsonException>(() => { new JPath("[]"); }, "Array index expected."); }
public void InvalidTemplate_CannotContainQuestionMark() { ExceptionAssert.Throws <RoutePatternException>( () => RoutePatternParser.Parse("foor?bar"), "The literal section 'foor?bar' is invalid. Literal sections cannot contain the '?' character."); }
public void MissingDotAfterIndexer() { ExceptionAssert.Throws <JsonException>(() => { new JPath("[1]Blah"); }, "Unexpected character following indexer: B"); }
static IEnumerable <CommandBaseTests.TestArgs <Command <T> > > _ExecutionSuccessful <T>() { var counter = new CommandBaseTests.CommandExecutionCounter(); var reentrancyContainer = new CommandBaseTests.ReentrancyContainer <Command <T> >(); void Execute(T arg) { counter.Execution++; if (reentrancyContainer.Command.RunningExecution != null) { counter.RunningExecution++; if (reentrancyContainer.Command.RunningExecution.CancelCommand != null) { counter.CancelCommand++; if (reentrancyContainer.Command.RunningExecution.CancelCommand.CanExecute() == reentrancyContainer.IsCancelCommandEnabled) { counter.IsCancelCommandEnabled++; } if (Math.Abs(reentrancyContainer.Command.RunningExecution.Progress) < float.Epsilon) { counter.Progress++; } } } if (!reentrancyContainer.Command.CanExecute(default(T))) { counter.CanExecuteWhileExecuting++; } // nested execution reentrancyContainer.Command.Execute(arg); } void ExecuteWithCancellationToken(T arg, CancellationToken cancellationToken) { if (cancellationToken.CanBeCanceled) { counter.CanBeCanceled++; } if (!cancellationToken.IsCancellationRequested) { counter.CancellationRequest++; } Execute(arg); } void ExecuteWithController(T arg, CommandExecutionController controller, CancellationToken cancellationToken) { if (controller != null) { counter.Controller++; } if (controller.Execution == reentrancyContainer.Command.RunningExecution) { counter.SameRunningExecution++; } ExecuteWithCancellationToken(arg, cancellationToken); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => controller.ReportProgress(-0.1f), "value"); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => controller.ReportProgress(1.1f), "value"); controller.ReportProgress(0.3f); if (Math.Abs(controller.Execution.Progress - 0.3f) < float.Epsilon) { counter.ProgressReporting++; } controller.DisableCancelCommand(); if (!controller.Execution.CancelCommand.CanExecute()) { counter.DisabledCancelCommand++; } ((IProgress <float>)controller).Report(-0.1f); ((IProgress <float>)controller).Report(1.1f); ((IProgress <float>)controller).Report(0.35f); if (Math.Abs(controller.Execution.Progress - 0.35f) < float.Epsilon) { counter.ProgressReportingAsIProgress++; } reentrancyContainer.CapturedController = controller; } foreach (var args in GetTestArgs(reentrancyContainer, Execute, ExecuteWithCancellationToken, ExecuteWithController)) { yield return(args); } Assert.AreEqual(reentrancyContainer.ExecutionCount, counter.Execution); Assert.AreEqual(counter.Execution, counter.RunningExecution); Assert.AreEqual(counter.Execution, counter.CancelCommand); Assert.AreEqual(counter.Execution, counter.IsCancelCommandEnabled); Assert.AreEqual(counter.Execution, counter.Progress); Assert.AreEqual(counter.Execution, counter.CanExecuteWhileExecuting); Assert.AreEqual(reentrancyContainer.ExecutionCount / 3 * 2, counter.CanBeCanceled); Assert.AreEqual(counter.CanBeCanceled, counter.CancellationRequest); Assert.AreEqual(reentrancyContainer.ExecutionCount / 3, counter.Controller); Assert.AreEqual(counter.Controller, counter.SameRunningExecution); Assert.AreEqual(counter.Controller, counter.ProgressReporting); Assert.AreEqual(counter.Controller, counter.ProgressReportingAsIProgress); Assert.AreEqual(counter.Controller, counter.DisabledCancelCommand); }