2016-06-22 18:05:52 -07:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
using NUnit.Framework ;
using MatterHackers.MatterControl.VersionManagement ;
using System.IO ;
using MatterHackers.MatterControl.DataStorage ;
using MatterHackers.MatterControl.SettingsManagement ;
using System.Threading ;
using MatterHackers.MatterControl.Tests.Automation ;
using MatterHackers.Agg.UI.Tests ;
using MatterHackers.GuiAutomation ;
using MatterHackers.Agg.UI ;
using Newtonsoft.Json ;
using MatterHackers.Agg.PlatformAbstract ;
2016-07-20 17:39:08 -07:00
using MatterHackers.MatterControl.SlicerConfiguration ;
2016-07-22 14:48:01 -07:00
using MatterHackers.MatterControl ;
2016-06-22 18:05:52 -07:00
namespace MatterControl.Tests.MatterControl
{
2016-07-22 14:48:01 -07:00
using OemProfileDictionary = Dictionary < string , Dictionary < string , string > > ;
2016-07-20 17:39:08 -07:00
[TestFixture]
2016-06-22 18:05:52 -07:00
public class RetrievePublicProfileTest
{
2016-07-22 15:21:24 -07:00
[Test, Category("FixNeeded")]
2016-07-22 15:01:24 -07:00
public async void GetPublicProfileList ( )
2016-06-22 18:05:52 -07:00
{
2016-07-22 15:21:24 -07:00
// This test needs to be moved to MCCentral to run against CloudServices or we need the duplicated local services API like the original CloudServicesv2 prototype had
/ *
2016-06-22 18:05:52 -07:00
StaticData . Instance = new MatterHackers . Agg . FileSystemStaticData ( Path . Combine ( ".." , ".." , ".." , ".." , "StaticData" ) ) ;
2016-07-25 15:21:25 -07:00
string profilePath = Path . Combine ( ApplicationDataStorage . ApplicationUserDataPath , "data" , "temp" , "cache" , "profiles" , "oemprofiles.json" ) ;
2016-07-20 17:39:08 -07:00
2016-06-22 18:05:52 -07:00
//MatterControlUtilities.OverrideAppDataLocation();
2016-07-22 15:01:24 -07:00
string resultsText = await CloudServices2 . MHWebServices . Instance . Devices . GetPublicProfileList ( ) ;
2016-07-22 14:48:01 -07:00
2016-07-22 15:01:24 -07:00
var oemProfiles = JsonConvert . DeserializeObject < OemProfileDictionary > ( resultsText ) ;
2016-06-22 18:05:52 -07:00
2016-07-22 15:01:24 -07:00
Assert . IsNotNull ( oemProfiles ) ;
2016-06-22 18:05:52 -07:00
2016-07-20 17:39:08 -07:00
//Ensures we got success and a list of profiles
2016-07-22 15:01:24 -07:00
Assert . IsTrue ( oemProfiles . Keys . Count > 5 ) ;
2016-06-22 18:05:52 -07:00
//Call Retrieve Profile next
RetrievePrinterProfileWorking ( ) ;
2016-07-22 15:21:24 -07:00
* /
2016-06-22 18:05:52 -07:00
}
2016-07-25 14:37:38 -07:00
[Test, Category("CloudProfiles"), Category("FixNeeded")]
public async void RetrievePrinterProfileWorking ( )
2016-06-22 18:05:52 -07:00
{
2016-07-25 14:37:38 -07:00
StaticData . Instance = new MatterHackers . Agg . FileSystemStaticData ( Path . Combine ( ".." , ".." , ".." , ".." , "StaticData" ) ) ;
2016-06-22 18:05:52 -07:00
string make = OemSettings . Instance . OemProfiles . First ( ) . Key ;
string model = OemSettings . Instance . OemProfiles [ make ] . First ( ) . Key ;
2016-07-25 14:37:38 -07:00
string deviceToken = OemSettings . Instance . OemProfiles [ make ] [ model ] ;
string cacheKey = deviceToken + ProfileManager . ProfileExtension ;
string expectedProfilePath = Path . Combine ( ApplicationDataStorage . ApplicationUserDataPath , "Profiles" , cacheKey ) ;
2016-06-22 18:05:52 -07:00
if ( File . Exists ( expectedProfilePath ) )
{
File . Delete ( expectedProfilePath ) ;
}
2016-06-23 18:30:51 -07:00
2016-07-25 14:37:38 -07:00
// Test will fail until mechanism can be created that exposes MHWebservices to vanilla MatterControl or until these tests are moved to MCCentral
2016-07-26 12:54:16 -07:00
var recievedPrinterProfile = await ApplicationController . DownloadPublicProfileAsync ( deviceToken ) ;
2016-06-22 18:05:52 -07:00
2016-07-26 12:54:16 -07:00
Assert . IsNotNull ( recievedPrinterProfile ) ;
2016-07-25 14:37:38 -07:00
2016-06-23 18:30:51 -07:00
//Assert.AreEqual(expectedProfilePath, recievedProfilePath,"Received Profile path does not match expected path.");
2016-06-22 18:05:52 -07:00
//Assert.IsTrue(File.Exists(expectedProfilePath));
}
}
}