Пример #1
0
            public void Initialize()
            {
                this.settings = new Mock <IEventSettings>();
                this.settings.SetupAllProperties();
                this.settings.Setup(x => x.CommandId).Returns(Guid.Empty);
                this.settings.Setup(x => x.EventId).Returns("EventId");
                this.settings.Setup(x => x.Owner.Name).Returns("EventAutomation");

                this.owner = new Mock <IProductElement>();
                this.owner.Setup(x => x.Info.AutomationSettings)
                .Returns(new[]
                {
                    // Note that this does not match the guid of the CommandId on the launchpoint
                    // settings, therefore it will not be found.
                    Mocks.Of <IAutomationSettingsInfo>().First(s => s.Id == Guid.NewGuid() && s.Name == "CommandName"),
                });

                this.automation = new EventAutomation(this.owner.Object, this.settings.Object);

                this.bindingFactory   = new Mock <IBindingFactory>();
                this.conditionBinding = new Mock <IDynamicBinding <ICondition> >();

                this.bindingFactory
                .Setup(x => x.CreateBinding <ICondition>(It.IsAny <IBindingSettings>()))
                .Returns(this.conditionBinding.Object);

                this.automation.BindingFactory = this.bindingFactory.Object;

                this.dynamicContext = new Mock <IDynamicBindingContext> {
                    DefaultValue = DefaultValue.Mock
                };
                this.bindingFactory.Setup(x => x.CreateContext()).Returns(this.dynamicContext.Object);
            }
Пример #2
0
            public virtual void Initialize()
            {
                Guid CommandId = Guid.NewGuid();

                this.settings = new Mock<IEventSettings>();
                this.settings.SetupAllProperties();
                this.settings.Setup(x => x.CommandId).Returns(CommandId);
                this.settings.Setup(x => x.EventId).Returns("EventId");
                this.settings.Setup(x => x.Owner.Name).Returns("EventAutomation");
                this.settings.Setup(x => x.Owner.AutomationSettings)
                    .Returns(new[]
                    {
                        Mocks.Of<IAutomationSettingsSchema>().First(s => s.Id == CommandId && s.Name == "CommandName"),
                    });

                Mock.Get(this.settings.Object.Owner.AutomationSettings.First())
                    .Setup(x => x.As<ICommandSettings>())
                    .Returns(Mocks.Of<ICommandSettings>().First(x => x.Name == "CommandName"));

                this.command = new Mock<IAutomationExtension>();
                this.command.Setup(x => x.Name).Returns("CommandName");

                var settingsInfo = Mocks.Of<IAutomationSettingsInfo>().First(s => s.Id == CommandId && s.Name == "CommandName");

                Mock.Get(settingsInfo).Setup(i => i.As<IAutomationSettings>()).Returns(
                    Mocks.Of<IAutomationSettings>().First(x => x.Id == CommandId && x.Name == "CommandName"));

                this.owner = new Mock<IProductElement>();
                this.owner.Setup(x => x.Info.AutomationSettings)
                    .Returns(new[]
                    {
                        settingsInfo,
                    });

                this.owner.Setup(x => x.BeginTransaction())
                    .Returns(Mock.Of<ITransaction>());

                this.owner.Setup(x => x.AutomationExtensions)
                    .Returns(new[]
                    {
                        this.command.Object,
                    });

                var ev = new Mock<IObservableEvent>();
                this.observable = ev.As<IObservable<IEvent<PropertyChangedEventArgs>>>();

                this.Automation = new EventAutomation(this.owner.Object, this.settings.Object);
                this.Automation.AllEvents = new[] 
                {
                    new Lazy<IObservableEvent, IIdMetadata>(
                        () => (IObservableEvent)this.observable.Object, 
                        Mocks.Of<IIdMetadata>().First(m => m.Id == "EventId"))
                };


                this.bindingFactory = new Mock<IBindingFactory>();
                this.conditionBinding = new Mock<IDynamicBinding<ICondition>>();

                this.bindingFactory
                    .Setup(x => x.CreateBinding<ICondition>(It.IsAny<IBindingSettings>()))
                    .Returns(this.conditionBinding.Object);

                this.Automation.BindingFactory = this.bindingFactory.Object;

                this.dynamicContext = new Mock<IDynamicBindingContext> { DefaultValue = DefaultValue.Mock };
                this.bindingFactory.Setup(x => x.CreateContext()).Returns(this.dynamicContext.Object);

            }
Пример #3
0
            public void Initialize()
            {
                this.settings = new Mock<IEventSettings>();
                this.settings.SetupAllProperties();
                this.settings.Setup(x => x.CommandId).Returns(Guid.Empty);
                this.settings.Setup(x => x.EventId).Returns("EventId");
                this.settings.Setup(x => x.Owner.Name).Returns("EventAutomation");

                this.owner = new Mock<IProductElement>();
                this.owner.Setup(x => x.Info.AutomationSettings)
                    .Returns(new[]
                    {
                        // Note that this does not match the guid of the CommandId on the launchpoint 
                        // settings, therefore it will not be found.
                        Mocks.Of<IAutomationSettingsInfo>().First(s => s.Id == Guid.NewGuid() && s.Name == "CommandName"),
                    });

                this.automation = new EventAutomation(this.owner.Object, this.settings.Object);

                this.bindingFactory = new Mock<IBindingFactory>();
                this.conditionBinding = new Mock<IDynamicBinding<ICondition>>();

                this.bindingFactory
                    .Setup(x => x.CreateBinding<ICondition>(It.IsAny<IBindingSettings>()))
                    .Returns(this.conditionBinding.Object);

                this.automation.BindingFactory = this.bindingFactory.Object;

                this.dynamicContext = new Mock<IDynamicBindingContext> { DefaultValue = DefaultValue.Mock };
                this.bindingFactory.Setup(x => x.CreateContext()).Returns(this.dynamicContext.Object);

            }
Пример #4
0
            public virtual void Initialize()
            {
                Guid CommandId = Guid.NewGuid();

                this.settings = new Mock <IEventSettings>();
                this.settings.SetupAllProperties();
                this.settings.Setup(x => x.CommandId).Returns(CommandId);
                this.settings.Setup(x => x.EventId).Returns("EventId");
                this.settings.Setup(x => x.Owner.Name).Returns("EventAutomation");
                this.settings.Setup(x => x.Owner.AutomationSettings)
                .Returns(new[]
                {
                    Mocks.Of <IAutomationSettingsSchema>().First(s => s.Id == CommandId && s.Name == "CommandName"),
                });

                Mock.Get(this.settings.Object.Owner.AutomationSettings.First())
                .Setup(x => x.As <ICommandSettings>())
                .Returns(Mocks.Of <ICommandSettings>().First(x => x.Name == "CommandName"));

                this.command = new Mock <IAutomationExtension>();
                this.command.Setup(x => x.Name).Returns("CommandName");

                var settingsInfo = Mocks.Of <IAutomationSettingsInfo>().First(s => s.Id == CommandId && s.Name == "CommandName");

                Mock.Get(settingsInfo).Setup(i => i.As <IAutomationSettings>()).Returns(
                    Mocks.Of <IAutomationSettings>().First(x => x.Id == CommandId && x.Name == "CommandName"));

                this.owner = new Mock <IProductElement>();
                this.owner.Setup(x => x.Info.AutomationSettings)
                .Returns(new[]
                {
                    settingsInfo,
                });

                this.owner.Setup(x => x.BeginTransaction())
                .Returns(Mock.Of <ITransaction>());

                this.owner.Setup(x => x.AutomationExtensions)
                .Returns(new[]
                {
                    this.command.Object,
                });

                var ev = new Mock <IObservableEvent>();

                this.observable = ev.As <IObservable <IEvent <PropertyChangedEventArgs> > >();

                this.Automation           = new EventAutomation(this.owner.Object, this.settings.Object);
                this.Automation.AllEvents = new[]
                {
                    new Lazy <IObservableEvent, IIdMetadata>(
                        () => (IObservableEvent)this.observable.Object,
                        Mocks.Of <IIdMetadata>().First(m => m.Id == "EventId"))
                };


                this.bindingFactory   = new Mock <IBindingFactory>();
                this.conditionBinding = new Mock <IDynamicBinding <ICondition> >();

                this.bindingFactory
                .Setup(x => x.CreateBinding <ICondition>(It.IsAny <IBindingSettings>()))
                .Returns(this.conditionBinding.Object);

                this.Automation.BindingFactory = this.bindingFactory.Object;

                this.dynamicContext = new Mock <IDynamicBindingContext> {
                    DefaultValue = DefaultValue.Mock
                };
                this.bindingFactory.Setup(x => x.CreateContext()).Returns(this.dynamicContext.Object);
            }