コード例 #1
0
        public void ShouldIgnoreDefaultValueIfInSession()
        {
            string sessionVal = "sessionValue";
            _session[VirtualFileProviderSessionHandler.SessionValueKey] = sessionVal;

            var provider = new VirtualFileProviderSessionHandler(_session, _factory);
            Assert.That(_session[VirtualFileProviderSessionHandler.SessionValueKey], Is.EqualTo(sessionVal));
        }
コード例 #2
0
        public void ShouldPersistValueChangeToSession()
        {
            string newVal = "newValue";

            var provider = new VirtualFileProviderSessionHandler(_session, _factory);
            provider.CurrentProviderKey = newVal;
            Assert.That(_session[VirtualFileProviderSessionHandler.SessionValueKey], Is.EqualTo(newVal));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public void ShouldResetProviderOnKeyChange()
        {
            var provider = new VirtualFileProviderSessionHandler(_session, _factory);

            _session[VirtualFileProviderSessionHandler.SessionDataKey] = new Object();
            provider.CurrentProviderKey = "irgendeinwert";

            Assert.That(_session[VirtualFileProviderSessionHandler.SessionDataKey], Is.Null);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }