test-project

why process give null inputstream in test runner class?

≡放荡痞女 提交于 2019-12-24 10:00:35
问题 In my android test project, I simply read the logcat using adb command like, public StringBuilder log=new StringBuilder(); public String line=""; public String temp=""; public void testSolo() throws Exception { String baseCommand = "logcat -v time"; baseCommand += " ActivityManager:I "; // Info for my app baseCommand += " *:S "; // Silence others try { Process logReaderProcess = Runtime.getRuntime().exec(baseCommand); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader

Autofac and DI for ValidationAttribute

假如想象 提交于 2019-12-13 22:01:07
问题 I have the following validation attribute class: public class ZipCodeValidationAttribute : ValidationAttribute { private readonly IValidationRepository _repository; public override bool IsValid(object value) { var repository = _repository; return repository.IsPostalCodeValid((string) value); } } To test I am trying to use Autofac as my IOC and use property injection. I've set up the test as follows: [TestMethod] public void When_PostalCodeAttribute_Given_ValidPostalCode_Then_SystemReturnsTrue