public void ProjectWithNullCollectionSourceProperty() { var customers = new[] { new Customer() }.AsQueryable(); var mapped = customers.Project().To<CustomerDto>().SingleOrDefault(); mapped.ShouldNotBeNull(); mapped.Addresses.ShouldBeNull(); }
public void ShouldBeAbleToSetEnum() { // Arrange var values = new[] { "1", "2", "3" }; // Act builder.Enum(values); // Assert builder.Data.Enum.ShouldEqual(values); }
public void ShouldHandleJustScriptArgs() { // Arrange var args = new[] { "--", "-port", "8080" }; // Act string[] scriptArgs; ScriptCsArgs.SplitScriptArgs(ref args, out scriptArgs); // Assert args.ShouldEqual(new string[0]); scriptArgs.ShouldEqual(new[] { "-port", "8080" }); }
public void ProjectWithAssignedCollectionSourceProperty() { var customer = new Customer { Addresses = new List<Address> { new Address(Street1), new Address(Street2) } }; var customers = new[] { customer }.AsQueryable(); var mapped = customers.Project().To<CustomerDto>().SingleOrDefault(); mapped.ShouldNotBeNull(); mapped.Addresses.ShouldBeOfLength(2); mapped.Addresses.ElementAt(0).Street.ShouldEqual(Street1); mapped.Addresses.ElementAt(1).Street.ShouldEqual(Street2); }
public void ShouldHandleExtraDoubledash() { // Arrange var args = new[] { "scriptname.csx", "-restore", "--", "-port", "--", "8080" }; // Act string[] scriptArgs; ScriptCsArgs.SplitScriptArgs(ref args, out scriptArgs); // Assert args.ShouldEqual(new[] { "scriptname.csx", "-restore" }); scriptArgs.ShouldEqual(new[] { "-port", "--", "8080" }); }
public void Throws_if_ints_is_null(int[] ints) { Should.Throw <ArgumentNullException>(() => ints.SplitBySequence(1, 2)); }
public void Accounts_MasterRegisterButtonForPostBack_Method_With_1_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange Object[] parametersOutRanged = { null, null }; Object[] parametersInDifferentNumber = { }; System.Exception exception, exception1, exception2, exception3, exception4; var accounts = CreateAnalyzer.CreateOrReturnStaticInstance <ecn.accounts.MasterPages.Accounts>(Fixture, out exception); var methodName = "MasterRegisterButtonForPostBack"; if (accounts != null) { // Act var masterRegisterButtonForPostBackMethodInfo1 = accounts.GetType().GetMethod(methodName); var masterRegisterButtonForPostBackMethodInfo2 = accounts.GetType().GetMethod(methodName); var returnType1 = masterRegisterButtonForPostBackMethodInfo1.ReturnType; var returnType2 = masterRegisterButtonForPostBackMethodInfo2.ReturnType; masterRegisterButtonForPostBackMethodInfo1.InvokeMethodInfo(accounts, out exception1, parametersOutRanged); masterRegisterButtonForPostBackMethodInfo2.InvokeMethodInfo(accounts, out exception2, parametersOutRanged); masterRegisterButtonForPostBackMethodInfo1.InvokeMethodInfo(accounts, out exception3, parametersInDifferentNumber); masterRegisterButtonForPostBackMethodInfo2.InvokeMethodInfo(accounts, out exception4, parametersInDifferentNumber); // Assert parametersOutRanged.ShouldNotBeNull(); parametersInDifferentNumber.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); accounts.ShouldNotBeNull(); masterRegisterButtonForPostBackMethodInfo1.ShouldNotBeNull(); masterRegisterButtonForPostBackMethodInfo2.ShouldNotBeNull(); if (exception1 != null) { Should.Throw(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersOutRanged), exceptionType: exception1.GetType()); Should.Throw(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersOutRanged), exceptionType: exception2.GetType()); } else { Should.NotThrow(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.NotThrow(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersOutRanged)); } if (exception1 != null) { Should.Throw(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersOutRanged), exceptionType: exception1.GetType()); Should.Throw(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersOutRanged), exceptionType: exception2.GetType()); } else { Should.NotThrow(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.NotThrow(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersOutRanged)); } Should.Throw <System.Exception>(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <System.Exception>(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.Throw <TargetParameterCountException>(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersOutRanged)); Should.Throw <TargetParameterCountException>(() => masterRegisterButtonForPostBackMethodInfo1.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(() => masterRegisterButtonForPostBackMethodInfo2.Invoke(accounts, parametersInDifferentNumber)); } else { // Act, Assert accounts.ShouldBeNull(); exception.ShouldNotBeNull(); } }
public void FailSilently() { Should.NotThrow(() => SystemUnderTest.PublishAsync(new GenericMessage()).Wait()); }
public void GetOption_DictIsNull_ThrowsNullArgException() { Dictionary <string, string> dict = null; Should.Throw <ArgumentNullException>(() => dict.GetOption("key")); }
public void OnWithNullHandlerThrows() { Should.Throw <ArgumentNullException>(() => _sut.OnWithNullHandler()); }
public void RestoreFromEventsThrows() { var events = new object[] { new Event(), new Event() }; Should.Throw <InvalidOperationException>(() => _sut.RestoreFromEvents(events)); }
public BatchFibonacci(int max, Should should) { this.max = max; this.should = should; }
public DelegateContinuation(Func <IOperationResult, TOut> func) { Should.NotBeNull(func, "func"); _func = func; _delegate = func; }
public DelegateContinuation(Action <IOperationResult <TIn> > genericAction) { Should.NotBeNull(genericAction, "genericAction"); _genericAction = genericAction; _delegate = genericAction; }
public DelegateContinuation(Action <IOperationResult> action) { Should.NotBeNull(action, "action"); _action = action; _delegate = action; }
public void DeserializeFails(string json) => Should.Throw <JsonException>(() => JsonSerializer.Deserialize <AggregatedProductOrder>(json, Options));
public void Result_Should_Throw_ArgumentNullException_When_Area_Is_Null() { var areaA = Area2D.Create(14, 10, 44, 15); Should.Throw <ArgumentNullException>(() => areaA.Join(null)); }
public void can_generate_output_for_a_collection_of_tags() { var tags = new[]{ new HtmlTag("div"), new HtmlTag("p"), new HtmlTag("div")}; var list = new TagList(tags); list.ToString().ShouldEqual("<div></div>\n<p></p>\n<div></div>"); }
public void can_be_used_as_a_tag_source() { var tags = new[] { new HtmlTag("div"), new HtmlTag("p"), new HtmlTag("div") }; var tagSource = (ITagSource)new TagList(tags); tagSource.AllTags().ShouldHaveTheSameElementsAs(tags); }
public void Throws_if_sequence_is_null_or_empty(int[] ints) { Should.Throw <ArgumentNullException>(() => ints.SplitBySequence(null)); Should.Throw <ArgumentException>(() => ints.SplitBySequence()); }
public BulkInsertFibonacciToDatabaseFromConnectionStringSettings(int max, Should should) { this.max = max; this.should = should; }
public DelegateContinuation(Func <IOperationResult <TIn>, TOut> genericFunc) { Should.NotBeNull(genericFunc, "genericFunc"); _genericFunc = genericFunc; _delegate = genericFunc; }
public DelegateContinuation(Action <TTarget, IOperationResult <TIn> > actionWithTarget) { Should.NotBeNull(actionWithTarget, "actionWithTarget"); _actionWithTarget = actionWithTarget; _delegate = actionWithTarget; }
public DelegateContinuation([NotNull] Func <TTarget, IOperationResult <TIn>, TOut> funcWithTarget) { Should.NotBeNull(funcWithTarget, "funcWithTarget"); _funcWithTarget = funcWithTarget; _delegate = funcWithTarget; }
public void ApplyWithNullEventThrows() { Should.Throw <ArgumentNullException>(() => _sut.ApplyWithNullEvent()); }
public void Throws_if_collection_is_null(IList <int> collection) { Should.Throw <ArgumentNullException>(() => collection.Random(10).ToList()); }
public static string GenerateNavigationParameter([NotNull] Type vmType, string value) { Should.NotBeNull(vmType, nameof(vmType)); return(vmType.AssemblyQualifiedName + IdSeparator[0] + value); }
public void Throws_if_count_is_less_than_one(IList <int> collection) { Should.Throw <ArgumentOutOfRangeException>(() => collection.Random(0).ToList()); Should.Throw <ArgumentOutOfRangeException>(() => collection.Random(-1).ToList()); }
/// <summary> /// Initializes a new instance of the <see cref="DataConstantValue" /> class. /// </summary> private DataConstantValue([NotNull] DataConstant dataConstant, object value) { Should.NotBeNull(dataConstant, "dataConstant"); DataConstant = dataConstant; Value = value; }
public MenuViewModel(IToastPresenter toastPresenter) { Should.NotBeNull(toastPresenter, nameof(toastPresenter)); _toastPresenter = toastPresenter; ExecuteCommand = new RelayCommand <MenuItemModel>(Execute); var root = new MenuItemModel { Name = "level 1", Items = new[] { new MenuItemModel { Name = "level 1.1", Items = new[] { new MenuItemModel { Name = "level 1.1.1" }, new MenuItemModel { Name = "level 1.1.2" } } }, new MenuItemModel { Name = "level 1.2", Items = new[] { new MenuItemModel { Name = "level 1.2.1" } } }, new MenuItemModel { Name = "level 1.3", Items = new[] { new MenuItemModel { Name = "level 1.3.1" } } } } }; Items = new[] { root, new MenuItemModel { Name = "level 2", Items = new[] { new MenuItemModel { Name = "level 2.1" } } } }; }
public void Constructor_ExecuteCanExecute_Otherwise_DoesNotThrowException() { var context = new TestContext(); Should.NotThrow(() => context.ConstructUUT_Execute_CanExecute()); }
public void If_TrueShouldThrow() { Should.Throw <ObjectDisposedException>(() => Raise.ObjectDisposedException.If(true, nameof(ObjectDisposedExceptionTests))); }
public void Accounts_HasAuthorized_Method_With_2_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange var userId = Fixture.Create <int>(); var clientId = Fixture.Create <int>(); Object[] parametersOutRanged = { userId, clientId, null }; Object[] parametersInDifferentNumber = { userId }; System.Exception exception, exception1, exception2, exception3, exception4; var accounts = CreateAnalyzer.CreateOrReturnStaticInstance <ecn.accounts.MasterPages.Accounts>(Fixture, out exception); var methodName = "HasAuthorized"; if (accounts != null) { // Act var hasAuthorizedMethodInfo1 = accounts.GetType().GetMethod(methodName); var hasAuthorizedMethodInfo2 = accounts.GetType().GetMethod(methodName); var returnType1 = hasAuthorizedMethodInfo1.ReturnType; var returnType2 = hasAuthorizedMethodInfo2.ReturnType; var result1 = hasAuthorizedMethodInfo1.GetResultMethodInfo <ecn.accounts.MasterPages.Accounts, bool>(accounts, out exception1, parametersOutRanged); var result2 = hasAuthorizedMethodInfo2.GetResultMethodInfo <ecn.accounts.MasterPages.Accounts, bool>(accounts, out exception2, parametersOutRanged); var result3 = hasAuthorizedMethodInfo1.GetResultMethodInfo <ecn.accounts.MasterPages.Accounts, bool>(accounts, out exception3, parametersInDifferentNumber); var result4 = hasAuthorizedMethodInfo2.GetResultMethodInfo <ecn.accounts.MasterPages.Accounts, bool>(accounts, out exception4, parametersInDifferentNumber); // Assert parametersOutRanged.ShouldNotBeNull(); parametersInDifferentNumber.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); accounts.ShouldNotBeNull(); hasAuthorizedMethodInfo1.ShouldNotBeNull(); hasAuthorizedMethodInfo2.ShouldNotBeNull(); result1.ShouldBe(result2); result3.ShouldBe(result4); if (exception1 != null) { Should.Throw(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersOutRanged), exceptionType: exception1.GetType()); Should.Throw(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersOutRanged), exceptionType: exception2.GetType()); } else { Should.NotThrow(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.NotThrow(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersOutRanged)); } if (exception1 != null) { Should.Throw(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersOutRanged), exceptionType: exception1.GetType()); Should.Throw(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersOutRanged), exceptionType: exception2.GetType()); } else { Should.NotThrow(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.NotThrow(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersOutRanged)); } Should.Throw <System.Exception>(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <System.Exception>(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersOutRanged)); Should.Throw <TargetParameterCountException>(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersOutRanged)); Should.Throw <TargetParameterCountException>(() => hasAuthorizedMethodInfo1.Invoke(accounts, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(() => hasAuthorizedMethodInfo2.Invoke(accounts, parametersInDifferentNumber)); } else { // Act, Assert accounts.ShouldBeNull(); exception.ShouldNotBeNull(); } }
public BatchFibonacciFromConnectionStringSettings(int max, Should should) : base(max, should) { }
public void Throws_if_count_is_negative(int[] ints) { Should.Throw <ArgumentOutOfRangeException>(() => ints.SplitBySequence(0, -1, 1, 2)); }
public BeGuid(Should<Guid, BeGuid> should, IAssertProvider assertProvider) { this.should = should; this.assertProvider = assertProvider; }
protected override void Check() { var c = new C { F = 1, G = 2, H = 3 }; GenerateCode(SerializationMode.Optimized, c); Serialize(); c.F = 31; c.G = 99; c.H = 77; Deserialize(); c.F.ShouldBe((short)1); c.G.ShouldBe((short)2); c.H.ShouldBe((short)3); c.F = -17; Should.Throw <RangeViolationException>(() => Serialize()); c.F = 99; Should.Throw <RangeViolationException>(() => Serialize()); c.F = 1; c.G = -9; c.H = -4; Serialize(); Deserialize(); c.F.ShouldBe((short)1); c.G.ShouldBe((short)-1); c.H.ShouldBe((short)6); c.G = -1; c.H = -2; Serialize(); Deserialize(); c.G.ShouldBe((short)-1); c.H.ShouldBe((short)-2); c.G = 0; c.H = 0; Serialize(); Deserialize(); c.G.ShouldBe((short)0); c.H.ShouldBe((short)0); c.G = 3; c.H = 6; Serialize(); Deserialize(); c.G.ShouldBe((short)3); c.H.ShouldBe((short)6); c.G = 4; c.H = 7; Serialize(); Deserialize(); c.G.ShouldBe((short)3); c.H.ShouldBe((short)-2); c.G = 40; c.H = 8; Serialize(); Deserialize(); c.G.ShouldBe((short)3); c.H.ShouldBe((short)-2); c.G = System.Int16.MaxValue; c.H = System.Int16.MaxValue; c.Q = System.Int16.MaxValue; Serialize(); Deserialize(); c.G.ShouldBe((short)3); c.H.ShouldBe((short)-2); c.Q.ShouldBe(System.Int16.MaxValue); c.G = System.Int16.MinValue; c.H = System.Int16.MinValue; c.Q = System.Int16.MinValue; Serialize(); Deserialize(); c.G.ShouldBe((short)-1); c.H.ShouldBe((short)6); c.Q.ShouldBe(System.Int16.MinValue); }
public BeNullableBool(Should<bool?, BeNullableBool> should, IAssertProvider assertProvider) { this.should = should; this.assertProvider = assertProvider; }
public void If_TrueShouldThrow_WithMessage() { Should.Throw <ObjectDisposedException>(() => Raise.ObjectDisposedException.If(true, nameof(ObjectDisposedExceptionTests), TestMessage)); }
public void ShouldHandleMissingDoubledash() { // Arrange var args = new[] { "scriptname.csx", "-restore" }; // Act string[] scriptArgs; ScriptCsArgs.SplitScriptArgs(ref args, out scriptArgs); // Assert args.ShouldEqual(new[] { "scriptname.csx", "-restore" }); scriptArgs.ShouldEqual(new string[0]); }
public BulkInsertFibonacciToDatabase(int max, Should should) { this.max = max; this.should = should; }
public void coerces_invalid_string_to_exception() { Should.Throw <InvalidOperationException>(() => _type.ParseValue("abcd")); }
public void coerces_numeric_string_to_decimal_throws() { Should.Throw <InvalidOperationException>(() => _type.ParseValue("12345.6579")); }
public async Task ExceptionIsThrown() { await Should.ThrowAsync <PublishException>(() => SystemUnderTest.PublishAsync(new SimpleMessage())); }
public OutputFibonacciToDatabase(int max, Should should) { this.max = max; this.should = should; }
public BeNullableDateTime(Should<DateTime?, BeNullableDateTime> should, IAssertProvider assertProvider) { this.should = should; this.assertProvider = assertProvider; }