public void ShouldIgnoreDefaultValueIfInSession() { string sessionVal = "sessionValue"; _session[VirtualFileProviderSessionHandler.SessionValueKey] = sessionVal; var provider = new VirtualFileProviderSessionHandler(_session, _factory); Assert.That(_session[VirtualFileProviderSessionHandler.SessionValueKey], Is.EqualTo(sessionVal)); }
public void ShouldPersistValueChangeToSession() { string newVal = "newValue"; var provider = new VirtualFileProviderSessionHandler(_session, _factory); provider.CurrentProviderKey = newVal; Assert.That(_session[VirtualFileProviderSessionHandler.SessionValueKey], Is.EqualTo(newVal)); }
public void ShouldCreateNewProviderBySelectedValueIfEmpty() { var fprovider = MockRepository.GenerateStub<IVirtualFileProvider>(); //_session[VirtualFileProviderSessionHandler.SessionDataKey] = fprovider; _factory.Stub(c => c.DefaultProviderKey).Return("Value"); _factory.Stub(c => c.GetProvider(Arg<string>.Is.Anything)).Return(fprovider); var provider = new VirtualFileProviderSessionHandler(_session, _factory); var result = provider.GetVirtualFileProvider(); _factory.AssertWasCalled(c => c.GetProvider(Arg.Is("Value"))); Assert.That(result, Is.SameAs(fprovider)); }
public void ShouldCreateSelectListFromProviders() { _factory.Stub(c => c.AvailableProviders).Return(new List<string>() { "Provider0", "Provider1" }); _factory.Stub(c => c.DefaultProviderKey).Return("Blub"); var provider = new VirtualFileProviderSessionHandler(_session, _factory); var selList = provider.Providers; Assert.That(selList.Count(), Is.EqualTo(2)); Assert.That(selList.First().Selected, Is.EqualTo(false)); Assert.That(selList.Last().Selected , Is.EqualTo(false)); }
public void ShouldResetProviderOnKeyChange() { var provider = new VirtualFileProviderSessionHandler(_session, _factory); _session[VirtualFileProviderSessionHandler.SessionDataKey] = new Object(); provider.CurrentProviderKey = "irgendeinwert"; Assert.That(_session[VirtualFileProviderSessionHandler.SessionDataKey], Is.Null); }
public void ShouldSetSelectedValueByDefaultValue() { _factory.Stub(c => c.AvailableProviders).Return(new List<string>() { "Provider0", "Provider2" }); _factory.Stub(c => c.DefaultProviderKey).Return("Provider2"); var provider = new VirtualFileProviderSessionHandler(_session, _factory); var selList = provider.Providers; Assert.That(selList.Count(), Is.EqualTo(2)); Assert.That(selList.Last().Selected, Is.EqualTo(true)); }
public void ShouldSetDefaultValueIfNotInSession() { string defValue = "default"; _factory.Stub(c => c.DefaultProviderKey).Return(defValue); var provider = new VirtualFileProviderSessionHandler(_session, _factory); Assert.That(_session[VirtualFileProviderSessionHandler.SessionValueKey], Is.EqualTo(defValue)); }
public void ShouldReturnStoredProviderIfPreviouslySet() { var fprovider = MockRepository.GenerateStub<IVirtualFileProvider>(); _session[VirtualFileProviderSessionHandler.SessionValueKey] = "irgendeinwett"; _session[VirtualFileProviderSessionHandler.SessionDataKey] = fprovider; var provider = new VirtualFileProviderSessionHandler(_session, _factory); _factory.AssertWasNotCalled(c => c.GetProvider(Arg<string>.Is.Anything)); var result = provider.GetVirtualFileProvider(); Assert.That(result, Is.SameAs(fprovider)); }