public void GetConfigurationAssemblyPath_TestNotDecoratedWithAssemblyFile_Exception() { MethodBase testMethod = MethodBase.GetCurrentMethod(); Assert.That(() => ExternalConfiguration.GetConfigurationAssemblyPath(testMethod), Throws.InstanceOf <MissingMemberException>() .With.Message.Contain(typeof(ConfigurationAssemblyAttribute).Name)); }
public void MissingChildrenElement_ExceptionWithMessageContaining() { string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod()); Assert.That(() => new CachingConfiguration(assemblyPath), Throws.InstanceOf <ConfigurationErrorsException>() .With.Message.Contain(ExceptionMessagePart.For.MissingRequiredChildElement <DependantCachesCollection>())); }
public void InvalidAttributeValue_ExceptionWithMessageContaining() { string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod()); Assert.That(() => new CachingConfiguration(assemblyPath), Throws.InstanceOf <ConfigurationErrorsException>() .With.Message.Contain(ExceptionMessagePart.For.InvalidAttributeValue(ExpirationElement.NAME))); }
public void UndefinedElement_ExceptionWithMessageContaining() { string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod()); Assert.That(() => new CachingConfiguration(assemblyPath), Throws.InstanceOf <ConfigurationErrorsException>() .With.Message.Contain(ExceptionMessagePart.For.UndefinedElement(ExpirationElement.ElementName))); }
public void GetConfigurationAssemblyPath_AssemblyFileNotAnAssembly_Exception() { MethodBase testMethod = MethodBase.GetCurrentMethod(); Assert.That(() => ExternalConfiguration.GetConfigurationAssemblyPath(testMethod), Throws.InstanceOf <ArgumentException>() .With.Message.Contain("\\notAnAssembly.txt").And .Property("ParamName").EqualTo("path")); }
public void WrongAttributeValue_ExceptionWithMessageContaining() { string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod()); //NOTE: for the exception to be thrown the element needs to be accessed Assert.That(() => new CachingConfiguration(assemblyPath).TimeToExpire("name"), Throws.InstanceOf <ConfigurationErrorsException>() .With.Message.Contain(ExceptionMessagePart.For.WrongMemberValue(ExpirationElement.VALUE))); }
public void GetConfigurationAssemblyPath_AssemblyFileDoesNotExist_Exception() { // in order to get the test method, we have to execute outside the delegate MethodBase testMethod = MethodBase.GetCurrentMethod(); Assert.That(() => ExternalConfiguration.GetConfigurationAssemblyPath(testMethod), Throws.InstanceOf <ArgumentException>() .With.Message.Contain("\\notExisting.dll").And .Property("ParamName").EqualTo("path")); }
public void GetConfigurationAssemblyPath_TestDecoratedWithAssemblyFile_AllowsAccessToConfigurationValuesFromCustomConfiguration() { string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod()); ICachingConfiguration subject = null; Assert.That(() => subject = new CachingConfiguration(assemblyPath), Throws.Nothing); Assert.That(subject.TimeToExpire("expiration1"), Is.EqualTo(1.Seconds())); Assert.That(subject.HasDependencies("cache2"), Is.True); Assert.That(subject.GetDependantCaches("cache1"), Is.EqualTo(new[] { "cache1_1", "cache1_2" })); }