static string FormatMessage(ConfigureResult result)
 {
     return "There were errors configuring the container:" +
            Environment.NewLine +
            string.Join(Environment.NewLine, result.Results
                .Select(x => string.Format("{0}: {1}", x.Key, x.Message)).ToArray());
 }
Пример #2
0
        public ConfigureResult Configure(ConfigureInput input)
        {
            var result = new ConfigureResult();

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                result.Error("This resource is only compatible with Windows.");
            }

            return(result);
        }
Пример #3
0
        public static void TestConfigureAndModified()
        {
            IEnumerable <IParameter> someCorrupt = new IParameter[]
            {
                new DummyParameter(false),
                new DummyParameter(true),
            };
            IConversationNodeData data = new DummyConversationNodeData(someCorrupt, Id <NodeTemp> .Parse("745fa8ce-174e-4af7-82b7-17e939e9a475"));
            Func <ConversationNode <DummyUI>, DummyUI> nodeUI      = n => new DummyUI(n, false);
            Func <ConversationNode <DummyUI>, DummyUI> corruptedUI = n => new DummyUI(n, true);
            ConversationNode <DummyUI> node = new ConversationNode <DummyUI>(data, nodeUI, corruptedUI);

            int modifications = 0;
            int undos         = 0;
            int redos         = 0;
            int expectedRedos = 0; //To ensure Modified is triggered AFTER the modification
            int expectedUndos = 0; //To ensure Modified is triggered AFTER the modification

            node.Modified += () => { modifications++; Assert.That(redos, Is.EqualTo(expectedRedos)); Assert.That(undos, Is.EqualTo(expectedUndos)); };
            Action          redo      = () => { redos++; };
            Action          undo      = () => { undos++; };
            ConfigureResult configure = node.Configure(n => new SimpleUndoPair()
            {
                Redo = redo, Undo = undo
            });

            Assert.That(undos, Is.EqualTo(0));
            Assert.That(redos, Is.EqualTo(0));
            Assert.That(modifications, Is.EqualTo(0));

            expectedRedos = 1;
            configure.Do(a => a.Redo(), b => Assert.Fail("Unexpected Cancelled configuration"));

            Assert.That(undos, Is.EqualTo(0));
            Assert.That(redos, Is.EqualTo(1));
            Assert.That(modifications, Is.EqualTo(1));

            expectedUndos = 1;
            configure.Do(a => a.Undo(), b => Assert.Fail("Unexpected Cancelled configuration"));

            Assert.That(undos, Is.EqualTo(1));
            Assert.That(redos, Is.EqualTo(1));
            Assert.That(modifications, Is.EqualTo(2));

            ConfigureResult cancelConfigure = node.Configure(n => ConfigureResultNotOk.Cancel);

            cancelConfigure.Do(a => Assert.Fail("Expected configure result to be Cancel"), b => Assert.That(b, Is.EqualTo(ConfigureResultNotOk.Cancel)));

            ConfigureResult notApplicableConfigure = node.Configure(n => ConfigureResultNotOk.NotApplicable);

            notApplicableConfigure.Do(a => Assert.Fail("Expected configure result to be Cancel"), b => Assert.That(b, Is.EqualTo(ConfigureResultNotOk.NotApplicable)));
        }
Пример #4
0
        public ConfigureResult Configure(ConfigureInput input)
        {
            _log.LogDebug("{method}: ", nameof(Configure));
            _log.LogTrace("->input = {@input}", input);
            _log.LogTrace("->state = {@state}", this);

            // TODO: configure and return any validation errors
            var result = new ConfigureResult();

            _log.LogTrace("<-state = {@state}", this);
            _log.LogTrace("<-result = {@result}", result);
            return(result);
        }
 public ContainerConfigurationException(ConfigureResult result, Exception innerException)
     : base(FormatMessage(result), innerException)
 {
 }
 public ContainerConfigurationException(ConfigureResult result)
     : base(FormatMessage(result))
 {
 }