public void ExistingFeatureIsUpdatedCorrectly() { string messageId = Guid.NewGuid().ToString(); Guid space = Guid.NewGuid(); Guid owner = Guid.NewGuid(); FeatureKey featureQuery = FeatureKey.Create(1, owner, space); Feature storedFeature = Feature.Create(1, owner, space, FeatureName); Feature updatedFeature = Feature.Create(1, owner, space, FeatureName); updatedFeature.Enabled = true; StandardFeatureStore standardFeatureStore = new StandardFeatureStore(m_StorageContainer); UpdateFeatureStateRequest request = UpdateFeatureStateRequest.Create(messageId, featureQuery, true); using (m_MockRepository.Record()) { Expect.Call(m_StorageContainer.Retrieve(featureQuery)).Return(storedFeature); Expect.Call(m_StorageContainer.Store(storedFeature)).Return(updatedFeature); m_MockRepository.ReplayAll(); UpdateFeatureStateResponse response = standardFeatureStore.UpdateFeatureState(request); Assert.AreEqual(messageId, response.Header.MessageId); Assert.AreEqual(1, response.Result.Id); Assert.AreEqual(space, response.Result.Space); Assert.IsTrue(response.Result.Enabled); m_MockRepository.VerifyAll(); } }
public void UpdateFeatureStateExceptionThrownWhenUpdatingNonExistentFeature() { string messageId = Guid.NewGuid().ToString(); Guid space = Guid.NewGuid(); Guid owner = Guid.NewGuid(); FeatureKey featureQuery = FeatureKey.Create(1, owner, space); StandardFeatureStore standardFeatureStore = new StandardFeatureStore(m_StorageContainer); UpdateFeatureStateRequest request = UpdateFeatureStateRequest.Create(messageId, featureQuery, true); using (m_MockRepository.Record()) { Expect.Call(m_StorageContainer.Retrieve(featureQuery)).Return(null); m_MockRepository.ReplayAll(); try { standardFeatureStore.UpdateFeatureState(request); Assert.Fail("Expected a UpdateFeatureStateException to be thrown"); } catch (UpdateFeatureStateException ex) { StringAssert.Contains(ex.Message, "Id 1"); StringAssert.Contains(ex.Message, "Space " + space); Assert.IsNotNull(ex.InnerException); } } }
/// <summary> /// Updates the state of a specified feature. /// </summary> /// <param name = "request"><see cref = "UpdateFeatureStateRequest" /> instance that defines the state necessary to update a specified Feature.</param> /// <returns> /// <see cref = "UpdateFeatureStateResponse" /> containing the results of the request to update the state of a specified Feature. /// </returns> public UpdateFeatureStateResponse UpdateFeatureState(UpdateFeatureStateRequest request) { UpdateFeatureStateResponse response; try { response = m_FeatureStoreImp.UpdateFeatureState(request); } catch (UpdateFeatureStateException e) { throw new FaultException <FeatureStoreFault>( FeatureStoreFault.Create(e.Message), new FaultReason( new FaultReasonText( e.Message, CultureInfo.CurrentCulture))); } return(response); }
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"); }