public void CachedConfigProviderCallsWorkerWork() { var stubWorker = MockRepository.GenerateStub<IConfigWorker<SampleClass>>(); var providerTest = new CachingConfigProvider<SampleClass>(stubWorker); providerTest.GetConfig(); stubWorker.AssertWasCalled(w => w.Work()); }
public void CachingConfigProviderCallsWorkOnce() { var workerStub = MockRepository.GenerateStub<IConfigWorker<SampleClass>>(); workerStub.Stub(w => w.Work()).Return(SampleObject); var providerTest = new CachingConfigProvider<SampleClass>(workerStub); providerTest.GetConfig(); providerTest.GetConfig(); workerStub.AssertWasCalled(w => w.Work(), o => o.Repeat.Once()); }
public void CachingConfigProviderReturnsSameConfigObjectEachTime() { var workerStub = MockRepository.GenerateStub<IConfigWorker<SampleClass>>(); workerStub.Stub(w => w.Work()).Return(SampleObject); var providerTest = new CachingConfigProvider<SampleClass>(workerStub); var a = providerTest.GetConfig(); var b = providerTest.GetConfig(); var c = providerTest.GetConfig(); Assert.AreEqual(a, b); Assert.AreEqual(b, c); }
public void CachingConfigProviderThrowsOnBadPath() { var provider = new CachingConfigProvider<object>(new FileInfo(@"bad/path/")); var failed = false; try { var config = provider.GetConfig(); } catch(DirectoryNotFoundException) { failed = true; } Assert.IsTrue(failed); }
public void CachingConfigProviderThrowsOnFileNotExist() { var provider = new CachingConfigProvider<object>(new FileInfo(@"C:/does.not.exist")); var failed = false; try { var config = provider.GetConfig(); } catch (FileNotFoundException) { failed = true; } Assert.IsTrue(failed); }