/// <summary>
        /// Creates the specified action.
        /// </summary>
        /// <param name="actionSettings">The settings associated with the action.</param>
        /// <returns>Returns an instance of the SyncAction which is an instance of IAction.</returns>
        /// <exception cref="ArgumentNullException">actionSettings
        /// or
        /// settings
        /// or
        /// serviceProvider</exception>
        /// <exception cref="InvalidOperationException">
        /// </exception>
        /// <exception cref="NotImplementedException"></exception>
        public override IAction Create(Library.Settings.Action actionSettings)
        {
            if (actionSettings == null)
            {
                throw new ArgumentNullException(nameof(actionSettings));
            }
            if (string.IsNullOrEmpty(actionSettings.SourceFeed))
            {
                throw new InvalidOperationException($"Source feed for action ({actionSettings.Name}) is empty. The Sync action must have a source feed");
            }
            if (string.IsNullOrEmpty(actionSettings.TargetFeed))
            {
                throw new InvalidOperationException($"Target feed for action ({actionSettings.Name}) is empty. The Sync action must have a target feed");
            }
            Debug.Assert(actionSettings.Type.Equals(Type, StringComparison.CurrentCultureIgnoreCase));

            var sourceRepository = GetRepository(actionSettings.SourceFeed);
            var targetRepository = GetRepository(actionSettings.TargetFeed);

            var action = ActivatorUtilities.CreateInstance <SyncAction>(ServiceProvider,
                                                                        actionSettings.CloneAndMergeSettings(ApplicationSettings.SettingsGroups.Find(actionSettings.SettingsGroup)),
                                                                        sourceRepository,
                                                                        targetRepository);

            return(action);
        }
        public void Test_Action_Properties()
        {
            var action = Fixture.Create <Library.Settings.Action>();
            var sut    = new Library.Settings.Action();

            sut.Enabled           = !action.Enabled;
            sut.FailOnError       = !action.FailOnError;
            sut.IncludePrerelease = !action.IncludePrerelease;
            sut.OnlyLatestVersion = !action.OnlyLatestVersion;
            sut.Name = action.Name;
            sut.PackagesToIgnore.AddRange(action.PackagesToIgnore);
            sut.SettingsGroup = action.SettingsGroup;
            sut.SourceFeed    = action.SourceFeed;
            sut.TargetFeed    = action.TargetFeed;
            sut.Type          = action.Type;

            Assert.True(!action.Enabled == sut.Enabled);
            Assert.True(!action.FailOnError == sut.FailOnError);
            Assert.True(!action.IncludePrerelease == sut.IncludePrerelease);
            Assert.True(!action.OnlyLatestVersion == sut.OnlyLatestVersion);
            Assert.True(action.Name == sut.Name);
            Assert.True(action.SettingsGroup == sut.SettingsGroup);
            Assert.True(action.SourceFeed == sut.SourceFeed);
            Assert.True(action.TargetFeed == sut.TargetFeed);
            Assert.True(action.Type == sut.Type);
            Assert.Equal(action.PackagesToIgnore, sut.PackagesToIgnore);
        }
Beispiel #3
0
 public IAction CreateAction(IServiceScope scope, Library.Settings.Action actionSettings)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 public IAction Create(Library.Settings.Action actionSettings)
 {
     return(new DummyAction());
 }