public void ExecuteResultWithNullContextThrows() { Assert.ThrowsArgumentNull( delegate { new ContentResult().ExecuteResult(null /* context */); }, "context"); }
public void ConstructorThrowsIfParameterInfoIsNull() { // Act & assert Assert.ThrowsArgumentNull( delegate { new ReflectedParameterDescriptor(null, new Mock <ActionDescriptor>().Object); }, "parameterInfo"); }
public void HttpSelfHostConfiguration_RelativeBaseAddressString_Throws() { Assert.ThrowsArgument(() => new HttpSelfHostConfiguration("relative"), "baseAddress"); }
public void Constructor_GuardClauses() { Assert.ThrowsArgumentNull(() => new HostedHttpRouteCollection(routeCollection: null), "routeCollection"); }
public void GetValidators_NonDateTimeValidatorTypes(string propertyName) { // Act & assert Assert.False(ReturnsValidator <ClientDataTypeModelValidatorProvider.DateModelValidator>(propertyName)); }
public void GetRouteData_GuardClauses() { Assert.ThrowsArgumentNull(() => _webApiRoutes.GetRouteData(request: null), "request"); }
public void Indexer_ForAspNetRoute_Throws() { _aspNetRoutes.Add("foo", new Mock <RouteBase>().Object); Assert.Throws <KeyNotFoundException>(() => _webApiRoutes["foo"], "The given key was not present in the dictionary."); }
public void ContentTypeCtorThrowsArgumentExceptionWhenContentTypeIsNull() { Assert.ThrowsArgumentNullOrEmpty(() => new ContentTypeAttribute(null), "contentType"); }
public void RedirectToAction_ThrowsIfControllerIsNull() { // Act & assert Assert.ThrowsArgumentNull( delegate { ((SampleController)null).RedirectToAction(x => x.SomeMethod(42)); }, "controller"); }
public void PrintWithInvalidEnumerationLength() { // Act & Assert Assert.ThrowsArgumentGreaterThan(() => ObjectInfo.Print(null, enumerationLength: -1), "enumerationLength", "0"); }
public void ContentTypeSetInCtor() { var attr = new ContentTypeAttribute("text/html"); Assert.Equal("text/html", attr.ContentType); }
public void PrintWithNegativeDepthThrows() { // Act & Assert Assert.ThrowsArgumentGreaterThanOrEqualTo(() => ObjectInfo.Print(null, depth: -1), "depth", "0"); }
public void EqualsToValidatorThrowsIfFieldIsNullOrEmpty() { // Act and Assert Assert.ThrowsArgumentNullOrEmptyString(() => Validator.EqualsTo(null), "otherFieldName"); }
public void RegexThrowsIfPatternIsNullOrEmpty() { // Act and Assert Assert.ThrowsArgumentNullOrEmptyString(() => Validator.Regex(null), "pattern"); Assert.ThrowsArgumentNullOrEmptyString(() => Validator.Regex(String.Empty), "pattern"); }
public void ConstructorRequiresNonNullHost() { Assert.ThrowsArgumentNull(() => new VBRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null), "host"); }
public void DecorateCodeParser_ThrowsOnNull() { MvcWebPageRazorHost host = new MvcWebPageRazorHost("foo.cshtml", "bar"); Assert.ThrowsArgumentNull(delegate() { host.DecorateCodeParser(null); }, "incomingCodeParser"); }
public void Constructor_WhenFormatterParameterIsNull_Throws() { Assert.ThrowsArgumentNull(() => new ContentNegotiationResult(formatter: null, mediaType: null), "formatter"); }
public void ConstructorWithNullActionThrows() { Assert.ThrowsArgumentNullOrEmpty( delegate { new HandleErrorInfo(new Exception(), "SomeController", null /* action */); }, "actionName"); }
public void GetVirtualPath_GuardClauses() { Assert.ThrowsArgumentNull(() => _webApiRoutes.GetVirtualPath(request: null, name: null, values: null), "request"); }
public void ConstructorWithNullControllerThrows() { Assert.ThrowsArgumentNullOrEmpty( delegate { new HandleErrorInfo(new Exception(), null /* controller */, "SomeAction"); }, "controllerName"); }
public void Indexer_ForUnknownRoute_Throws() { Assert.Throws <KeyNotFoundException>(() => _webApiRoutes["foo"], "The given key was not present in the dictionary."); }
public void ConstructorWithNullExceptionThrows() { Assert.ThrowsArgumentNull( delegate { new HandleErrorInfo(null /* exception */, "SomeController", "SomeAction"); }, "exception"); }
public void GetValidators_NumericValidatorTypes(string propertyName) { // Act & assert Assert.True(ReturnsValidator <ClientDataTypeModelValidatorProvider.NumericModelValidator>(propertyName)); }
public void ConstructorThrowsIfModelMetadataIsNull() { // Act & assert Assert.ThrowsArgumentNull( delegate { new ModelValidationNode(null, "someKey"); }, "modelMetadata"); }
public void ConstructorThrowsIfActionDescriptorIsNull() { // Act & assert Assert.ThrowsArgumentNull( delegate { new ReflectedParameterDescriptor(new Mock <ParameterInfo>().Object, null); }, "actionDescriptor"); }
public void ConstructorRequiresNonEmptyClassName() { Assert.ThrowsArgumentNullOrEmptyString(() => new VBRazorCodeGenerator(String.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className"); }
public void HttpSelfHostConfiguration_NullBaseAddressString_Throws() { Assert.ThrowsArgumentNull(() => new HttpSelfHostConfiguration((string)null), "baseAddress"); }
public void ConstructorRequiresNonNullRootNamespaceName() { Assert.ThrowsArgumentNull(() => new VBRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()), "rootNamespaceName"); }
public void HttpSelfHostConfiguration_QueryBaseAddressString_Throws() { Assert.ThrowsArgument(() => new HttpSelfHostConfiguration("http://localhost?somequery"), "baseAddress"); }
public void GeneratedJTokenTest() { Random rndGen = new Random(1); int oldMaxArray = CreatorSettings.MaxArrayLength; int oldMaxList = CreatorSettings.MaxListLength; int oldMaxStr = CreatorSettings.MaxStringLength; double oldNullProbability = CreatorSettings.NullValueProbability; bool oldCreateAscii = CreatorSettings.CreateOnlyAsciiChars; CreatorSettings.MaxArrayLength = 5; CreatorSettings.MaxListLength = 3; CreatorSettings.MaxStringLength = 3; CreatorSettings.NullValueProbability = 0; CreatorSettings.CreateOnlyAsciiChars = true; JTokenCreatorSurrogate jsonValueCreator = new JTokenCreatorSurrogate(); try { for (int i = 0; i < 1000; i++) { JToken jv = (JToken)jsonValueCreator.CreateInstanceOf(typeof(JToken), rndGen); if (jv.Type == JTokenType.Array || jv.Type == JTokenType.Object) { string jaStr = FormUrlEncoding(jv); byte[] data = Encoding.UTF8.GetBytes(jaStr); for (var cnt = 1; cnt <= data.Length; cnt += 4) { ICollection <KeyValuePair <string, string> > collection; FormUrlEncodedParser parser = FormUrlEncodedParserTests.CreateParser(data.Length + 1, out collection); Assert.NotNull(parser); int totalBytesConsumed; ParserState state = FormUrlEncodedParserTests.ParseBufferInSteps(parser, data, cnt, out totalBytesConsumed); Assert.Equal(ParserState.Done, state); Assert.Equal(data.Length, totalBytesConsumed); JObject deserJo = FormUrlEncodedJson.Parse(collection); Assert.NotNull(deserJo); bool compare = true; if (((IDictionary <string, JToken>)deserJo).ContainsKey("JV")) { compare = JTokenRoundTripComparer.Compare(jv, deserJo["JV"]); } else { compare = JTokenRoundTripComparer.Compare(jv, deserJo); } Assert.True(compare, "Comparison failed for test instance " + i); } } } } finally { CreatorSettings.MaxArrayLength = oldMaxArray; CreatorSettings.MaxListLength = oldMaxList; CreatorSettings.MaxStringLength = oldMaxStr; CreatorSettings.NullValueProbability = oldNullProbability; CreatorSettings.CreateOnlyAsciiChars = oldCreateAscii; } }