public void Create_Run_SaveRestore_Proceed_Task_Submit_Item_To_Ebay()
        {
            try {
                var dispatcher = Dispatcher.Instance;
                var store = new DemoshopStoreManager();

                store.CreateTask( StoreTaskType.SubmitToEbay );
                store.SaveData();
                store.LoadData();

                dispatcher.RunChannelTasks( store.GetChannelTasks() );
                dispatcher.ProceedChannelTasks( store.GetChannelTasks() );

                store.SaveData();
                store.LoadData();

                Assert.AreEqual( 1, store.StoreTasks.Count );
                Assert.AreEqual( 3, store.GetChannelTasks().Count() );

                store.GetEbaySubmissionTasks().ForEach( t => {
                    Console.WriteLine();
                    Console.WriteLine( t );
                    Assert.IsTrue(
                        t.GetStatusCode() == TaskStatus.InProgress || t.GetStatusCode() == TaskStatus.Success,
                        "Success or InProgress" );
                    Assert.IsNotNull( t.EbaySubmissionResponse.Result.MipSubmissionId );
                    Assert_That_Text_Contains( t, "ArgsInfo" );
                } );
            }
            catch( SpreadbotException exception ) {
                IgnoreMipQueueDepthErrorMessage( exception.Message );
            }
        }
        public void ChannelTasks_LastUpdateTime()
        {
            try {
                var dispatcher = Dispatcher.Instance;
                var store = new DemoshopStoreManager();

                store.CreateTask( StoreTaskType.SubmitToEbay );
                Assert_That_Last_Update_Time_is_Correct( store );

                dispatcher.RunChannelTasks( store.GetChannelTasks() );
                Assert_That_Last_Update_Time_is_Correct( store );

                dispatcher.ProceedChannelTasks( store.GetChannelTasks() );
                Assert_That_Last_Update_Time_is_Correct( store );
            }
            catch( SpreadbotException exception ) {
                IgnoreMipQueueDepthErrorMessage( exception.Message );
            }
        }
        public void Run_Task_Submit_Item_To_Amazon()
        {
            using( var store = new DemoshopStoreManager() ) {
                var task = store.CreateTask( StoreTaskType.SubmitToAmazon );
                Dispatcher.Instance.RunChannelTasks( store.GetChannelTasks() );

                task.AbstractSubTasks.OfType< AmazonSubmissionTask >().ForEach( t => {
                    //IgnoreMipQueueDepthErrorMessage( t.AmazonSubmissionResponse );
                    Console.WriteLine( t.AmazonSubmissionResponse );
                    Assert.AreEqual( TaskStatus.InProgress, t.GetStatusCode() );
                    Assert.IsNotNull( t.AmazonSubmissionResponse.Result.MwsRequestId );
                } );
                Assert.AreEqual( TaskStatus.InProgress, task.GetStatusCode() );
            }
        }
        public void Task_Num_Is_The_Same_After_Reload_With_Deleting()
        {
            var store = new DemoshopStoreManager();
            store.CreateTask( StoreTaskType.SubmitToEbay );
            var taskNum = store.GetChannelTasks().Count();

            store.SaveData();
            store.DeleteAllTasks();
            store.LoadData();

            Assert.AreEqual( 1, store.StoreTasks.Count(), "Store Task Num" );
            var task = store.StoreTasks.First();
            Assert.AreEqual( taskNum, task.AbstractSubTasks.Count(), "Sub Tasks num" );
        }
        public void Save_and_Restore_Tasks()
        {
            var store = new DemoshopStoreManager();

            store.CreateTask( StoreTaskType.SubmitToEbay );
            store.SaveData();
            store.DeleteAllTasks();
            store.LoadData();

            Assert.AreEqual( 1, store.StoreTasks.Count );
            Assert.AreEqual( 3, store.GetChannelTasks().Count() );

            var feeds =
                store.GetChannelTasks()
                    .OfType< EbaySubmissionTask >()
                    .Select( t => t.Args.MipFeedDescriptor.Type )
                    .OrderBy( f => f.ToString() ).ToArray();

            Assert.AreEqual( 3, feeds.Count() );
            Assert.AreEqual( MipFeedType.Availability, feeds[ 0 ] );
            Assert.AreEqual( MipFeedType.Distribution, feeds[ 1 ] );
            Assert.AreEqual( MipFeedType.Product, feeds[ 2 ] );
        }
        public void Proceed_Task_Submit_Item_To_Ebay()
        {
            try {
                var dispatcher = Dispatcher.Instance;
                var store = new DemoshopStoreManager();
                var task = store.CreateTask( StoreTaskType.SubmitToEbay );

                dispatcher.RunChannelTasks( store.GetChannelTasks() );
                dispatcher.ProceedChannelTasks( store.GetChannelTasks() );

                task.AbstractSubTasks.OfType< EbaySubmissionTask >().ForEach( t => {
                    IgnoreMipQueueDepthErrorMessage( t.EbaySubmissionResponse );
                    Console.WriteLine( t );
                    Assert.IsTrue( t.GetStatusCode() == TaskStatus.InProgress || t.GetStatusCode() == TaskStatus.Success );
                    Assert.IsNotNull( t.EbaySubmissionResponse.Result.MipSubmissionId );
                } );
                Assert.AreEqual( TaskStatus.InProgress, task.GetStatusCode() );
            }
            catch( SpreadbotException exception ) {
                IgnoreMipQueueDepthErrorMessage( exception.Message );
            }
        }