Exemple #1
0
        public void CheckFeatureStateThrowsFeatureStoreFaultExceptionOnException()
        {
            IStorageContainer storageContainer = m_MockRepository.StrictMock <IStorageContainer>();
            FeatureKey        key = FeatureKey.Create(1, Guid.NewGuid(), Guid.NewGuid());

            using (m_MockRepository.Record())
            {
                Expect.Call(storageContainer.Retrieve(FeatureKey.Create(key.Id, key.OwnerId, key.Space))).Throw(
                    new CheckFeatureStateException("Bad Mojo Exception"));
                m_MockRepository.ReplayAll();

                FeatureStoreService featureStoreService = new FeatureStoreService(storageContainer);

                try
                {
                    featureStoreService.CheckFeatureState(
                        CheckFeatureStateRequest.Create(
                            "CheckFeatureStateThrowsFeatureStoreFaultExceptionOnException",
                            key));

                    Assert.Fail("Expecting FaultException<FeatureStoreFault>");
                }
                catch (FaultException <FeatureStoreFault> e)
                {
                    Console.WriteLine(e.Detail.Message);
                    Console.WriteLine(e.Message);
                    StringAssert.Contains(e.Detail.Message,
                                          "An exception occurred querying the data store for the Feature.");
                }

                m_MockRepository.VerifyAll();
            }
        }
Exemple #2
0
        public void CreateFeatureThrowsFeatureStoreFaultExceptionOnException()
        {
            IStorageContainer storageContainer = m_MockRepository.StrictMock <IStorageContainer>();
            Feature           feature          = Feature.Create(1, Guid.NewGuid(), Guid.NewGuid(),
                                                                "CreateFeatureThrowsCreateFeatureFaultOnException");

            using (m_MockRepository.Record())
            {
                Expect.Call(storageContainer.Retrieve(FeatureKey.Create(feature.Id, feature.OwnerId, feature.Space))).
                Throw(new CreateFeatureException("Bad Mojo Exception"));
                m_MockRepository.ReplayAll();

                FeatureStoreService featureStoreService = new FeatureStoreService(storageContainer);

                try
                {
                    featureStoreService.CreateFeature(
                        CreateFeatureRequest.Create(
                            "CreateFeatureThrowsCreateFeatureFaultOnException",
                            feature));

                    Assert.Fail("Expecting FaultException<FeatureStoreFault>");
                }
                catch (FaultException <FeatureStoreFault> e)
                {
                    Console.WriteLine(e.Detail.Message);
                    Console.WriteLine(e.Message);
                    StringAssert.Contains(e.Detail.Message, "Bad Mojo Exception");
                }

                m_MockRepository.VerifyAll();
            }
        }
Exemple #3
0
        public void RetrieveDefinedFeaturesThrowsFeatureStoreFaultExceptionOnException()
        {
            IStorageContainer storageContainer = m_MockRepository.StrictMock <IStorageContainer>();
            FeatureScope      scope            = FeatureScope.Create(Guid.NewGuid(), Guid.NewGuid());

            using (m_MockRepository.Record())
            {
                Expect.Call(storageContainer.Retrieve(scope)).Throw(new CheckFeatureStateException("Bad Mojo Exception"));
                m_MockRepository.ReplayAll();

                FeatureStoreService featureStoreService = new FeatureStoreService(storageContainer);

                try
                {
                    featureStoreService.RetrieveDefinedFeatures(
                        RetrieveDefinedFeaturesRequest.Create(
                            "UpdateFeatureStateThrowsFeatureStoreFaultExceptionOnException",
                            scope));

                    Assert.Fail("Expecting FaultException<FeatureStoreFault>");
                }
                catch (FaultException <FeatureStoreFault> e)
                {
                    Console.WriteLine(e.Detail.Message);
                    Console.WriteLine(e.Message);
                    StringAssert.Contains(e.Detail.Message, "An exception occurred retrieving defined Features.");
                }

                m_MockRepository.VerifyAll();
            }
        }
        public void NonExistingFeaturesAreDisabledByDefault()
        {
            var baseProvider = Base;

            baseProvider.SetupGet(p => p.Features)
            .Returns(new Dictionary <string, bool>());

            var sut = new FeatureStoreService(baseProvider.Object, DummyOverlay.Object);

            Assert.False(sut.IsEnabled("FakeFeature"));
        }
        public void CanQueryNonExistingFeatures()
        {
            var baseProvider = Base;

            baseProvider.SetupGet(p => p.Features)
            .Returns(new Dictionary <string, bool>());

            var sut = new FeatureStoreService(baseProvider.Object, DummyOverlay.Object);

            var ex = Record.Exception(() => sut.IsEnabled("FakeFeature"));

            Assert.Null(ex);
        }
        public void PlatformOverlayReplacesDefaultValue(bool baseValue, bool overlayValue)
        {
            var baseProvider = Base;

            baseProvider.SetupGet(p => p.Features)
            .Returns(new Dictionary <string, bool> {
                ["Foo"] = baseValue
            });

            var overlay = Overlay;

            overlay.SetupGet(p => p.Overrides)
            .Returns(new Dictionary <string, bool> {
                ["Foo"] = overlayValue
            });

            var sut = new FeatureStoreService(baseProvider.Object, overlay.Object);

            Assert.Equal(overlayValue, sut.IsEnabled("Foo"));
        }