예제 #1
0
        public void RetrieveFeaturesForOwnerId()
        {
            string          messageId = Guid.NewGuid().ToString();
            Guid            ownerId   = Guid.NewGuid();
            IList <Feature> features  = new List <Feature>
            {
                Feature.Create(1, ownerId, Guid.Empty, "Feature One"),
                Feature.Create(1, ownerId, Guid.NewGuid(), "Feature Two"),
                Feature.Create(1, ownerId, Guid.NewGuid(), "Feature Three")
            };

            IFeatureStore featureStore             = new StandardFeatureStore(m_StorageContainer);
            FeatureScope  featureScope             = FeatureScope.Create(ownerId, Guid.Empty);
            RetrieveDefinedFeaturesRequest request = RetrieveDefinedFeaturesRequest.Create(messageId, featureScope);

            using (m_MockRepository.Record())
            {
                Expect.Call(m_StorageContainer.Retrieve(featureScope)).Return(features);
                m_MockRepository.ReplayAll();

                RetrieveDefinedFeaturesResponse response = featureStore.RetrieveDefinedFeatures(request);

                Assert.AreEqual(request.Header.MessageId, response.Header.MessageId);
                foreach (Feature feature in response.Result)
                {
                    Assert.AreEqual(ownerId, feature.OwnerId);
                }

                m_MockRepository.VerifyAll();
            }
        }
예제 #2
0
        public void RetrieveDefinedFeaturesExceptionThrown()
        {
            string    messageId = Guid.NewGuid().ToString();
            Exception exception = m_MockRepository.StrictMock <Exception>();

            RetrieveDefinedFeaturesRequest request = RetrieveDefinedFeaturesRequest.Create(messageId,
                                                                                           FeatureScope.Create(
                                                                                               Guid.NewGuid(),
                                                                                               Guid.NewGuid()));

            IFeatureStore featureStore = new StandardFeatureStore(m_StorageContainer);

            using (m_MockRepository.Record())
            {
                Expect.Call(m_StorageContainer.Retrieve(request.FeatureScope)).Throw(exception);

                m_MockRepository.ReplayAll();

                try
                {
                    featureStore.RetrieveDefinedFeatures(request);
                    Assert.Fail("Expected FeatureCreationException");
                }
                catch (RetrieveDefinedFeaturesException)
                {
                }

                m_MockRepository.VerifyAll();
            }
        }
예제 #3
0
        /// <summary>
        ///   Retrieves the defined features.
        /// </summary>
        /// <param name = "request"><see cref = "RetrieveDefinedFeaturesRequest" /> instance containing the criteria by which the <see
        ///    cref = "Feature" />s are selected.</param>
        /// <returns>
        ///   <see cref = "RetrieveDefinedFeaturesResponse" /> instance containing the results based on the given criteria.
        /// </returns>
        public RetrieveDefinedFeaturesResponse RetrieveDefinedFeatures(RetrieveDefinedFeaturesRequest request)
        {
            RetrieveDefinedFeaturesResponse response;

            try
            {
                response = m_FeatureStoreImp.RetrieveDefinedFeatures(request);
            }
            catch (RetrieveDefinedFeaturesException e)
            {
                throw new FaultException <FeatureStoreFault>(
                          FeatureStoreFault.Create(e.Message),
                          new FaultReason(
                              new FaultReasonText(
                                  e.Message,
                                  CultureInfo.CurrentCulture)));
            }

            return(response);
        }
예제 #4
0
        public void ExerciseFullInterface()
        {
            Debug.WriteLine("BEGIN: ExerciseFullInterface");

            CacheSwappingStorageContainer cacheSwappingStorageContainer =
                new CacheSwappingStorageContainer(@".\ExerciseFullInterface_Storage.dat");
            StandardFeatureStore standardFeatureStore = new StandardFeatureStore(cacheSwappingStorageContainer);

            /* -- CreateFeature -- */

            CreateFeatureRequest createFeatureRequest1 = CreateFeatureRequest.Create(
                Guid.NewGuid().ToString(),
                Feature.Create(
                    1,
                    Guid.NewGuid(),
                    Guid.NewGuid(),
                    "Feature One"));

            CreateFeatureRequest createFeatureRequest2 = CreateFeatureRequest.Create(
                Guid.NewGuid().ToString(),
                Feature.Create(
                    2,
                    Guid.NewGuid(),
                    Guid.NewGuid(),
                    "Feature Two"));

            CreateFeatureRequest createFeatureRequest3 = CreateFeatureRequest.Create(
                Guid.NewGuid().ToString(),
                Feature.Create(
                    3,
                    Guid.NewGuid(),
                    Guid.NewGuid(),
                    "Feature Three"));

            CreateFeatureResponse createFeatureResponse = standardFeatureStore.CreateFeature(createFeatureRequest1);

            AssertCreateFeatureResponse(createFeatureRequest1, createFeatureResponse);

            createFeatureResponse = standardFeatureStore.CreateFeature(createFeatureRequest2);
            AssertCreateFeatureResponse(createFeatureRequest2, createFeatureResponse);

            createFeatureResponse = standardFeatureStore.CreateFeature(createFeatureRequest3);
            AssertCreateFeatureResponse(createFeatureRequest3, createFeatureResponse);

            AssertPerformanceCountersRecorded(PerformanceCounterReporterType.CreateFeature, false, 3);

            /* -- CheckFeatureState -- */

            CheckFeatureStateRequest checkFeatureStateRequest1 =
                CheckFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest1.Feature.Id,
                        createFeatureRequest1.Feature.OwnerId,
                        createFeatureRequest1.Feature.Space));
            CheckFeatureStateResponse checkFeatureStateResponse =
                standardFeatureStore.CheckFeatureState(checkFeatureStateRequest1);

            AssertCheckFeatureStateResponse(checkFeatureStateRequest1, checkFeatureStateResponse);

            CheckFeatureStateRequest checkFeatureStateRequest2 =
                CheckFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest2.Feature.Id,
                        createFeatureRequest2.Feature.OwnerId,
                        createFeatureRequest2.Feature.Space));

            checkFeatureStateResponse = standardFeatureStore.CheckFeatureState(checkFeatureStateRequest2);
            AssertCheckFeatureStateResponse(checkFeatureStateRequest2, checkFeatureStateResponse);

            CheckFeatureStateRequest checkFeatureStateRequest3 =
                CheckFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest3.Feature.Id,
                        createFeatureRequest3.Feature.OwnerId,
                        createFeatureRequest3.Feature.Space));

            checkFeatureStateResponse = standardFeatureStore.CheckFeatureState(checkFeatureStateRequest3);
            AssertCheckFeatureStateResponse(checkFeatureStateRequest3, checkFeatureStateResponse);

            AssertPerformanceCountersRecorded(PerformanceCounterReporterType.CheckFeatureState, false, 3);

            /* -- UpdateFeatureState -- */

            UpdateFeatureStateRequest updateFeatureStateRequest1 =
                UpdateFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest1.Feature.Id,
                        createFeatureRequest1.Feature.OwnerId,
                        createFeatureRequest1.Feature.Space),
                    true);
            UpdateFeatureStateResponse updateFeatureStateResponse =
                standardFeatureStore.UpdateFeatureState(updateFeatureStateRequest1);

            Assert.IsTrue(updateFeatureStateResponse.Result.Enabled);

            UpdateFeatureStateRequest updateFeatureStateRequest2 =
                UpdateFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest2.Feature.Id,
                        createFeatureRequest2.Feature.OwnerId,
                        createFeatureRequest2.Feature.Space),
                    true);

            updateFeatureStateResponse = standardFeatureStore.UpdateFeatureState(updateFeatureStateRequest2);
            Assert.IsTrue(updateFeatureStateResponse.Result.Enabled);

            UpdateFeatureStateRequest updateFeatureStateRequest3 =
                UpdateFeatureStateRequest.Create(
                    Guid.NewGuid().ToString(),
                    FeatureKey.Create(
                        createFeatureRequest3.Feature.Id,
                        createFeatureRequest3.Feature.OwnerId,
                        createFeatureRequest3.Feature.Space),
                    true);

            updateFeatureStateResponse = standardFeatureStore.UpdateFeatureState(updateFeatureStateRequest3);
            Assert.IsTrue(updateFeatureStateResponse.Result.Enabled);

            AssertPerformanceCountersRecorded(PerformanceCounterReporterType.UpdateFeatureState, false, 3);

            /* -- RetrieveDefinedFeatures -- */

            RetrieveDefinedFeaturesRequest retrieveDefinedFeaturesRequest = RetrieveDefinedFeaturesRequest.Create(
                Guid.NewGuid().ToString(),
                FeatureScope.Create(createFeatureRequest1.Feature.OwnerId, createFeatureRequest1.Feature.Space));

            RetrieveDefinedFeaturesResponse retrieveDefinedFeaturesResponse =
                standardFeatureStore.RetrieveDefinedFeatures(retrieveDefinedFeaturesRequest);

            Assert.IsNotNull(retrieveDefinedFeaturesResponse.Result);
            Assert.IsTrue(retrieveDefinedFeaturesResponse.Result.GetEnumerator().MoveNext());

            AssertPerformanceCountersRecorded(PerformanceCounterReporterType.RetrieveDefinedFeatures, true, 1);

            Debug.WriteLine("END: ExerciseFullInterface");
        }