public void ItRaisesAnEventWhenTheServiceResponseContainsAnError()
        {
            var          numberOfErrorEvents = 0;
            const string errorMessage        = "Error Message";

            _treeNodeService.ErrorGettingChildTreeNodes += (s, e) =>
            {
                numberOfErrorEvents++;
                Assert.AreEqual(errorMessage, e.ErrorMessage);
            };

            var numberOfCallbacks = 0;

            const string promptName      = "Prompt Name";
            const string parameterName   = "Parameter Name";
            var          parameterValues = A.ObservableCollection(A.ParameterValue().Build(), A.ParameterValue().Build());

            var treeNode = Mock.Of <ITreeNode>(n => n.GetParameterValueHierarchy() == parameterValues);

            _fakeChildPromptLevelServiceClient.SetupGetChildren(promptName, parameterName, parameterValues);

            _treeNodeService.GetChildrenFor(promptName, parameterName, treeNode, n =>
            {
                numberOfCallbacks++;
            });

            Assert.AreEqual(0, numberOfCallbacks);

            _fakeChildPromptLevelServiceClient.RaiseGetChildrenError(errorMessage);

            Assert.AreEqual(0, numberOfCallbacks);
            Assert.AreEqual(1, numberOfErrorEvents);
        }
Beispiel #2
0
        public void ItUsesTheErrorCallbacktWhenTheCallbackContainsAnError()
        {
            const string errorMessage        = "Error Message";
            var          numberOfErrorEvents = 0;

            var numberOfChildPromptItemEvents = 0;

            const string promptName    = "Prompt Name";
            const string parameterName = "Parameter Name";
            const string value         = "Value";

            _fakePromptLevelServiceClient.SetupGetChildren2(
                promptName,
                parameterName,
                value);

            _childPromptItemsService.GetChildren(
                promptName,
                parameterName,
                value,
                c =>
            {
                numberOfChildPromptItemEvents++;
            },
                e =>
            {
                numberOfErrorEvents++;
                Assert.AreEqual(errorMessage, e);
            });

            Assert.AreEqual(0, numberOfChildPromptItemEvents);

            _fakePromptLevelServiceClient.RaiseGetChildrenError(errorMessage);

            Assert.AreEqual(0, numberOfChildPromptItemEvents);
            Assert.AreEqual(1, numberOfErrorEvents);
        }