public void SafeDelete_should_delete_directories_with_readonly_files() { var dir = CreateDir(@"\TestDir"); CreateDir(@"\TestDir\SubDir"); CreateFile(@"\TestDir\SubDir\testFile", true); Executing.This(() => FilesystemTools.SafeDelete(dir, true)).Should().Throw(); FilesystemTools.SafeDelete(dir, true, true); Directory.Exists(dir).Should().Be.False(); }
public void WhenMapDictionaryWithWrongValueTypeThenThrows() { var mapper = new ModelMapper(); Executing.This(() => mapper.Class <MyClass>(mc => { mc.Id(x => x.Id); mc.Map <int, int>("Map", y => y.Access(Accessor.Field)); })).Should().Throw <MappingException>(); }
public void Flush() { var filename = "TeaFileTTest_Flush.tea"; var tf = TeaFile <int> .Create(filename); tf.Write(Enumerable.Range(1, 10)); tf.Flush(); // we can easily test only that the call does not except tf.Close(); Executing.This(tf.Flush).Should().Throw(); // and that it fails after closing the stream }
public void WhenMapListWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); Executing.This(() => mapper.Class <MyClass>(mc => { mc.Id(x => x.Id); mc.Set <int>("Set", y => y.Access(Accessor.Field)); })).Should().Throw <MappingException>(); }
public void WhenMemberPropertyRefAcceptOnlyMemberOfExpectedType() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(typeof(MyClass).GetProperty("Relation"), hbm); mapper.PropertyReference(typeof(Relation).GetProperty("Whatever")); hbm.propertyref.Should().Be("Whatever"); Executing.This(() => mapper.PropertyReference(typeof(Array).GetProperty("Length"))).Should().Throw <ArgumentOutOfRangeException>(); }
public void WhenMapAnyWithWrongTypeThenThrows() { var mapper = new ModelMapper(); Executing.This(() => mapper.Class <MyClass>(mc => { mc.Id(x => x.Id); mc.Any <Related>("Any", typeof(int), y => y.Access(Accessor.Field)); })).Should().Throw <MappingException>(); }
public void WhenMapManyToOneWithWrongTypeThenThrows() { var mapper = new ModelMapper(); Executing.This(() => mapper.Class <MyClass>(mc => { mc.Id(x => x.Id); mc.ManyToOne <object>("ManyToOne", y => y.Access(Accessor.Field)); })).Should().Throw <MappingException>(); }
public void SafeDelete_should_delete_directories_recursively_when_specified() { var dir = CreateDir(@"\TestDir"); CreateDir(@"\TestDir\SubDir"); CreateFile(@"\TestDir\SubDir\testFile"); Executing.This(() => FilesystemTools.SafeDelete(dir)).Should().Throw(); FilesystemTools.SafeDelete(dir, true); Directory.Exists(dir).Should().Be.False(); }
public void CreateNewInstance_should_throw_ArgumentNullException_on_null_jobOrderNumberGenerator() { Executing.This(() => JobOrder.Factory.CreateNewInstance(null, Guid.NewGuid(), Guid.NewGuid(), 101, "GBP", DateTime.Now, DateTime.Now.AddMonths(1), true, "A job order", null, "Description")) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("jobOrderNumberGenerator"); }
private static void PublishCore(object message, List <IEventAggregatorHandler> handlers) { for (var i = 0; i < handlers.Count; i++) { var task = handlers[i].HandleAsync(message); Observe(task); if (!task.IsCompleted) { Executing?.Invoke(null, new TaskEventArgs(task)); } } }
public void CreateNewEntry_should_throw_ArgumentException_on_blank_lastName() { Executing.This(() => Person.Factory.CreateNewEntry("Andrea", "", "FAKE", "FAKE", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("lastName"); }
public void Ctor_should_throw_ArgumentNullException_if_image_parameter_is_null() { Executing.This(() => new ImageResult(null, "image/jpeg")) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("image"); }
public void Ctor_should_throw_on_null_database_argument() { Executing.This(() => new HomeControllerWorkerServices(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("database"); }
public void Ctor_should_throw_ArgumentNullException_on_null_bus_and_value_of_parameter_should_be_bus() { Executing.This(() => new TestableSaga(null, null, null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("bus"); }
public void MarketingServices_Ctor_should_Throw_ArgumentNullException_on_Null_CustomerRepository() { Executing.This(() => new MarketingServices(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("customerRepository"); }
public void Factory_should_throw_ArgumentException_on_blank_firstName() { Executing.This(() => Person.Factory.CreateNewEntry("", "Saltarello", DateTime.Now)) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("firstName"); }
public void Ctor_should_throw_ArgumentException_on_null_Currency() { Executing.This(() => new Money(42, null)) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("currency"); }
public void Ctor_should_throw_ArgumentException_if_pattern_parameter_is_whitespace() { Executing.This(() => new NotEqualConstraint(" ")) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("pattern"); }
public void ExoticCoverage() { Executing.This(() => TeaFile.OpenRead((string)null)).Should().Throw <ArgumentNullException>(); Executing.This(() => TeaFile.OpenRead((Stream)null)).Should().Throw <ArgumentNullException>(); var stream = TestUtils.GetTeaFileEventInt7Values(); var tf = TeaFile.OpenRead(stream); Executing.This(() => tf.GetFieldValue(null, null)).Should().Throw <ArgumentNullException>(); Item item = new Item(2); Executing.This(() => tf.GetFieldValue(item, null)).Should().Throw <ArgumentNullException>(); }
public void WhenGetInheritedClassUsingInterfaceThenNotThrows() { using (var scenario = new ScenarioWithB(Sfi)) { using (var s = OpenSession()) { INamed loadedEntity = null; Executing.This(() => loadedEntity = s.Get <INamed>(scenario.B.Id)).Should().NotThrow(); loadedEntity.Should().Be.OfType <B>(); } } }
public void Ctor_should_throw_on_null_workerServices_argument() { Executing.This(() => new CartController(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("workerServices"); }
public void IdMetaTypeShouldBeImmutableAfterAddMetaValues() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.IdType(NHibernateUtil.Int32)).Should().NotThrow(); Executing.This(mapper.IdType <int>).Should().NotThrow(); Executing.This(mapper.IdType <string>).Should().Throw <ArgumentException>(); Executing.This(() => mapper.IdType(NHibernateUtil.String)).Should().Throw <ArgumentException>(); }
public void CreateNewEntry_should_throw_ArgumentException_on_null_firstName() { Executing.This(() => Person.Factory.CreateNewEntry(null, "Saltarello", "FAKE", "FAKE", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("firstName"); }
public void WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass() { var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof(MyComponent)); Executing.This(() => { inspector.AddAsTablePerConcreteClassEntity(typeof(MyComponent)); inspector.IsTablePerConcreteClass(typeof(MyComponent)); }).Should().Throw <MappingException>(); }
public void Ctor_should_throw_ArgumentNullException_on_null_cart_parameter() { Executing.This(() => new CartCommands(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("cart"); }
public void Ctor_should_throw_ArgumentNullException_on_null_bus_and_value_of_parameter_should_be_bus() { Executing.This(() => new NServiceBusEventDispatcher(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("bus"); }
public void Ctor_should_throw_ArgumentException_on_amount_less_than_zero() { Executing.This(() => new PositiveMoney(-1, "EUR")) .Should() .Throw <ArgumentException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("amount"); }
public void Ctor_should_throw_ArgumentNullException_on_null_container_parameter() { Executing.This(() => new UnityTypeResolver(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("container"); }
public void Ctor_should_throw_ArgumentNullException_if_feed_parameter_is_null() { Executing.This(() => new Rss20Result(null)) .Should() .Throw <ArgumentNullException>() .And .ValueOf .ParamName .Should() .Be .EqualTo("feed"); }
public void FormatValueToFilter_FileTimeDateTimeCollection_ThrowsNotSupportedException() { //prepare var dates = new Collection <DateTime>(new[] { DateTime.Now, DateTime.Now.AddDays(1) }); _mappingArguments.PropertyType = typeof(Collection <DateTime>); var propertyMapping = new DateCollectionPropertyMapping <DateCollectionPropertyMappingTest>(_mappingArguments, null); //act Executing.This(() => propertyMapping.FormatValueToFilter(dates)) .Should().Throw <NotSupportedException>(); }