Example #1
0
        public SpaceCard()
        {
            InitializeComponent();

            _viewModel = new SpacesViewModel();
            _dataStore = new MockDataStore();
        }
Example #2
0
        public void DisplayAlert(Alert item)
        {
            Task.Run(async() =>
            {
                var locator = CrossGeolocator.Current;

                var position    = await locator.GetLastKnownLocationAsync();
                double distance = 1;
                if (position != null)
                {
                    distance = new Coordinates(position.Latitude, position.Longitude)
                               .DistanceTo(
                        new Coordinates(item.Lat, item.Lon),
                        UnitOfLength.Kilometers
                        );
                }

                if (distance <= item.Distance)
                {
                    var dataStore = new MockDataStore();
                    await dataStore.AddItemAsync(item);
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        var view = new ItemDetailPage(new ItemDetailViewModel(item));
                        await MainPage.Navigation.PushModalAsync(view);
                    });
                }
            });
        }
Example #3
0
 public ProcessedImageViewModel()
 {
     Title                     = "PMS";
     DataStore                 = new MockDataStore();
     ProcessedImages           = new ObservableCollection <ProcessedImage>();
     LoadProcessedImageCommand = new Command(async() => await ExecuteLoadProcessedImagesCommand());
 }
Example #4
0
 public UserListViewModel()
 {
     Task.Run(async() => {
         MockDataStore db = new MockDataStore();
         AddressList      = new ObservableCollection <Item>(await db.GetItemsAsync(true));
     });
 }
Example #5
0
        public void ProcessEnvHigherThanUserConfig()
        {
            const string retryKey = "Retry";
            const string envName  = "ENV_FOR_RETRY";
            var          config   = new SimpleTypedConfig <int>(retryKey, "", -1, envName);

            var path      = Path.GetRandomFileName();
            var dataStore = new MockDataStore();

            dataStore.WriteFile(path,
                                @"{
    ""Az"": {
        ""Retry"": 100
    }
}");
            var env = new MockEnvironmentVariableProvider();

            env.Set(envName, "10", System.EnvironmentVariableTarget.Process);

            IConfigManager icm = GetConfigManager(
                new InitSettings()
            {
                DataStore = dataStore,
                Path      = path,
                EnvironmentVariableProvider = env
            },
                config);

            Assert.Equal(10, icm.GetConfigValue <int>(retryKey));
        }
        public void CanExportConfig()
        {
            string key           = "key1";
            var    config        = new SimpleTypedConfig <bool>(key, "", true);
            string configPath    = Path.GetTempFileName();
            var    dataStore     = new MockDataStore();
            var    configManager = GetConfigManager(
                new InitSettings()
            {
                DataStore = dataStore,
                Path      = configPath
            },
                config);

            // update config to false
            configManager.UpdateConfig(key, false, ConfigScope.CurrentUser);

            // export config file
            string path = Path.GetTempFileName();

            Assert.False(dataStore.FileExists(path));
            new JsonConfigHelper(configPath, dataStore).ExportConfigFile(path);

            // config file should be exported and be correct
            Assert.True(dataStore.FileExists(path));
            var json = JsonUtilities.DeserializeJson(dataStore.ReadFileAsText(path), true);

            Assert.True(json.ContainsKey(ConfigFilter.GlobalAppliesTo));
            var jsonConfig = json.GetProperty(ConfigFilter.GlobalAppliesTo) as IDictionary <string, object>;

            Assert.NotNull(jsonConfig);
            Assert.False((bool)jsonConfig.GetProperty(key));
        }
        public void CanImportConfig()
        {
            string key           = "key1";
            var    config        = new SimpleTypedConfig <bool>(key, "", true);
            var    dataStore     = new MockDataStore();
            var    configManager = GetConfigManager(
                new InitSettings()
            {
                DataStore = dataStore
            },
                config);

            // import a config file
            string path = Path.GetTempFileName();

            dataStore.WriteFile(path,
                                @"{
    ""Az"": {
        ""key1"": false
    }
}");
            new JsonConfigHelper(configManager.ConfigFilePath, dataStore).ImportConfigFile(path);
            configManager.BuildConfig();

            // configs should be imported correctly
            Assert.False(configManager.GetConfigValue <bool>(key));
        }
        public void ExportImportE2E()
        {
            string key           = "key1";
            var    config        = new SimpleTypedConfig <bool>(key, "", true);
            var    dataStore     = new MockDataStore();
            var    configManager = GetConfigManager(
                new InitSettings()
            {
                DataStore = dataStore
            },
                config);

            // update
            configManager.UpdateConfig(key, false, ConfigScope.CurrentUser);

            // exportconfig
            string path   = Path.GetRandomFileName();
            var    helper = new JsonConfigHelper(configManager.ConfigFilePath, dataStore);

            helper.ExportConfigFile(path);

            // clear
            configManager.ClearConfig(key, ConfigScope.CurrentUser);
            Assert.True(configManager.GetConfigValue <bool>(key));

            // import
            helper.ImportConfigFile(path);
            configManager.BuildConfig();
            Assert.False(configManager.GetConfigValue <bool>(key));
        }
        public void LoadingProfileWorks()
        {
            string contents  = @"{
  ""Environments"": {
    ""testCloud"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    }
  },
  ""Context"": {
    ""TokenCache"": ""AgAAAAAAAAA="",
    ""Account"": {
      ""Id"": ""*****@*****.**"",
      ""Type"": 1,
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Subscription"": {
      ""Id"": ""00000000-0000-0000-0000-000000000000"",
      ""Name"": ""Contoso Test Subscription"",
      ""Environment"": ""testCloud"",
      ""Account"": ""*****@*****.**"",
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Environment"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    },
    ""Tenant"": {
      ""Id"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6"",
      ""Domain"": ""contoso.com""
    }
  }
}";
            var    path      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.Instance.ProfileFile);
            var    dataStore = new MockDataStore();

            AzureSession.Instance.DataStore = dataStore;
            dataStore.WriteFile(path, contents);
            var profile = new AzureRmProfile(path);

            Assert.Equal(5, profile.Environments.Count());
            Assert.Equal("3c0ff8a7-e8bb-40e8-ae66-271343379af6", profile.DefaultContext.Tenant.Id.ToString());
            Assert.Equal("contoso.com", profile.DefaultContext.Tenant.Directory);
            Assert.Equal("00000000-0000-0000-0000-000000000000", profile.DefaultContext.Subscription.Id.ToString());
            Assert.Equal("testCloud", profile.DefaultContext.Environment.Name);
            Assert.Equal("*****@*****.**", profile.DefaultContext.Account.Id);
            Assert.Equal(AzureAccount.AccountType.User, profile.DefaultContext.Account.Type);
            Assert.Equal(new byte[] { 2, 0, 0, 0, 0, 0, 0, 0 }, profile.DefaultContext.TokenCache.CacheData);
            Assert.Equal(path, profile.ProfilePath);
        }
Example #10
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Notes.Clear();
                var notes = await MockDataStore.GetNotesAsync();

                foreach (var note in notes)
                {
                    Notes.Add(note);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void TestUninstallAzureRmUnauthorized()
        {
            var dataStore = new MockDataStore();

            AzureSession.Instance.DataStore = dataStore;
            dataStore.CreateDirectory("testmodulepath");
            dataStore.CreateDirectory(Path.Combine("testmodulepath", "AzureRM.ApiManagement"));
            dataStore.WriteFile(Path.Combine("testmodulepath", Path.Combine("AzureRM.ApiManagement", "file1")), new byte[2]);
            dataStore.LockAccessToFile(Path.Combine("testmodulepath", "AzureRM.ApiManagement"));
            // Ensure read does not throw
            Assert.True(dataStore.DirectoryExists(Path.Combine("testmodulepath", "AzureRM.ApiManagement")));

            var cmdlet = new UninstallAzureRmCommand();

            Environment.SetEnvironmentVariable("PSModulePath", "testmodulepath");
            try
            {
                cmdlet.ExecuteCmdlet();
                // Throw incorrect exception if cmdlet does not throw
                Assert.True(false);
            }
            catch (UnauthorizedAccessException e)
            {
                Assert.Equal("Module deletion failed. Please close all PowerShell sessions to ensure no AzureRM modules are currently loaded, and rerun this cmdlet in Administrator mode.", e.Message);
            }
        }
Example #12
0
        public void LoadingProfileWorks()
        {
            string contents  = @"{
  ""Environments"": {
    ""testCloud"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    }
  },
  ""Context"": {
    ""TokenCache"": ""AQIDBAUGCAkA"",
    ""Account"": {
      ""Id"": ""*****@*****.**"",
      ""Type"": 1,
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Subscription"": {
      ""Id"": ""00000000-0000-0000-0000-000000000000"",
      ""Name"": ""Contoso Test Subscription"",
      ""Environment"": ""testCloud"",
      ""Account"": ""*****@*****.**"",
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Environment"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    },
    ""Tenant"": {
      ""Id"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6"",
      ""Domain"": ""contoso.com""
    }
  }
}";
            string path      = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile);
            var    dataStore = new MockDataStore();

            AzureSession.DataStore = dataStore;
            dataStore.WriteFile(path, contents);
            var profile = new AzureRMProfile(path);

            Assert.Equal(4, profile.Environments.Count);
            Assert.Equal("3c0ff8a7-e8bb-40e8-ae66-271343379af6", profile.Context.Tenant.Id.ToString());
            Assert.Equal("contoso.com", profile.Context.Tenant.Domain);
            Assert.Equal("00000000-0000-0000-0000-000000000000", profile.Context.Subscription.Id.ToString());
            Assert.Equal("testCloud", profile.Context.Environment.Name);
            Assert.Equal("*****@*****.**", profile.Context.Account.Id);
            Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 8, 9, 0 }, profile.Context.TokenCache);
            Assert.Equal(path, profile.ProfilePath);
        }
        public MainWindow()
        {
            InitializeComponent();
            MockDataStore store = new MockDataStore();

            Items            = store.GetItemsAsync().Result;
            this.DataContext = this;
        }
Example #14
0
 public ProfileCmdltsTests() : base()
 {
     dataStore = new MockDataStore();
     ProfileClient.DataStore = dataStore;
     commandRuntimeMock      = new MockCommandRuntime();
     SetMockData();
     AzureSession.SetCurrentContext(null, null, null);
 }
Example #15
0
        public TestPage()
        {
            InitializeComponent();

            var ds = new MockDataStore();

            loggedIn = ds.GetLoggedStatus();
        }
        public void ProfileSerializeDeserializeWorks()
        {
            var dataStore = new MockDataStore();

            AzureSession.DataStore = dataStore;
            var profilePath    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.ProfileFile);
            var currentProfile = new AzureRMProfile(profilePath);
            var tenantId       = Guid.NewGuid().ToString();
            var environment    = new AzureEnvironment
            {
                Name      = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id         = "*****@*****.**",
                Type       = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenantId } }
            };
            var sub = new AzureSubscription
            {
                Account     = account.Id,
                Environment = environment.Name,
                Id          = new Guid(),
                Name        = "Contoso Test Subscription",
                Properties  = { { AzureSubscription.Property.Tenants, tenantId } }
            };
            var tenant = new AzureTenant
            {
                Id     = new Guid(tenantId),
                Domain = "contoso.com"
            };

            currentProfile.Context = new AzureContext(sub, account, environment, tenant);
            currentProfile.Environments[environment.Name] = environment;
            currentProfile.Context.TokenCache             = new byte[] { 1, 2, 3, 4, 5, 6, 8, 9, 0 };

            AzureRMProfile deserializedProfile;
            // Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                // "Save" object state
                bf.Serialize(ms, currentProfile);

                // Re-use the same stream for de-serialization
                ms.Seek(0, 0);

                // Replace the original exception with de-serialized one
                deserializedProfile = (AzureRMProfile)bf.Deserialize(ms);
            }
            Assert.NotNull(deserializedProfile);
            var jCurrentProfile      = currentProfile.ToString();
            var jDeserializedProfile = deserializedProfile.ToString();

            Assert.Equal(jCurrentProfile, jDeserializedProfile);
        }
Example #17
0
        public void Test1()
        {
            var store = new MockDataStore();

            Item item = store.GetItemsAsync().Result.First();

            Assert.NotNull(item);
            // Assert.False(true);
        }
Example #18
0
        public async Task Test1()
        {
            var x = new MockDataStore();
            await x.AddItemAsync(new Item());

            var count = (await x.GetItemsAsync()).Count();

            Assert.True(count == 7);
        }
Example #19
0
 private void Button_Clicked(object sender, EventArgs e)
 {
     if (!loggedIn)
     {
         var ds = new MockDataStore();
         ds.SetLoggedStatus(true);
         Navigation.PopModalAsync();
     }
 }
Example #20
0
        public void Test1()
        {
            //Act
            var result = new MockDataStore();
            //Arrange
            var collection = result.GetItemsAsync(false);

            //Assert
            Assert.Empty(collection.Result);
        }
Example #21
0
        private void getData()
        {
            MockDataStore mockData = new MockDataStore();

            foreach (var m in mockData.items)
            {
                names.Add(m.Name);
                items.Add(m);
            }
        }
        public void ProfileSerializeDeserializeWorks()
        {
            var dataStore   = new MockDataStore();
            var profilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.Instance.ProfileFile);
            var profile     = new AzureSMProfile(profilePath);

            AzureSession.Instance.DataStore = dataStore;
            var tenant      = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name            = "testCloud",
                ActiveDirectory = new Uri("http://contoso.com")
            };
            var account = new AzureAccount
            {
                Id   = "*****@*****.**",
                Type = AzureAccount.AccountType.User,
            };

            account.SetTenants(tenant);
            var sub = new AzureSubscription
            {
                Id   = new Guid().ToString(),
                Name = "Contoso Test Subscription",
            };

            sub.SetAccount(account.Id);
            sub.SetEnvironment(environment.Name);
            sub.SetTenant(tenant);

            profile.EnvironmentTable[environment.Name] = environment;
            profile.AccountTable[account.Id]           = account;
            profile.SubscriptionTable[sub.GetId()]     = sub;

            AzureSMProfile deserializedProfile;
            // Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                // "Save" object state
                bf.Serialize(ms, profile);

                // Re-use the same stream for de-serialization
                ms.Seek(0, 0);

                // Replace the original exception with de-serialized one
                deserializedProfile = (AzureSMProfile)bf.Deserialize(ms);
            }
            Assert.NotNull(deserializedProfile);
            var jCurrentProfile      = JsonConvert.SerializeObject(profile);
            var jDeserializedProfile = JsonConvert.SerializeObject(deserializedProfile);

            Assert.Equal(jCurrentProfile, jDeserializedProfile);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var dataStore = new MockDataStore();
            var newItem   = new Item()
            {
                Text = txtItemText.Text, Description = txtItemDetail.Text
            };

            dataStore.AddItemAsync(newItem).Wait();
            Close();
        }
        public void ProfileSerializeDeserializeWorks()
        {
            var dataStore      = new MockDataStore();
            var currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));

            AzureSession.DataStore = dataStore;
            var client      = new ProfileClient(currentProfile);
            var tenant      = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name      = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id         = "*****@*****.**",
                Type       = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenant } }
            };
            var sub = new AzureSubscription
            {
                Account     = account.Id,
                Environment = environment.Name,
                Id          = new Guid(),
                Name        = "Contoso Test Subscription",
                Properties  = { { AzureSubscription.Property.Tenants, tenant } }
            };

            client.AddOrSetEnvironment(environment);
            client.AddOrSetAccount(account);
            client.AddOrSetSubscription(sub);

            AzureProfile deserializedProfile;
            // Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                // "Save" object state
                bf.Serialize(ms, currentProfile);

                // Re-use the same stream for de-serialization
                ms.Seek(0, 0);

                // Replace the original exception with de-serialized one
                deserializedProfile = (AzureProfile)bf.Deserialize(ms);
            }
            Assert.NotNull(deserializedProfile);
            var jCurrentProfile      = JsonConvert.SerializeObject(currentProfile);
            var jDeserializedProfile = JsonConvert.SerializeObject(deserializedProfile);

            Assert.Equal(jCurrentProfile, jDeserializedProfile);
        }
Example #25
0
        private List <MultiDialogsBot.Entity> GetEntitiesAsync(EntitiesQuery searchQuery)
        {
            var entities = new List <MultiDialogsBot.Entity>();

            MockDataStore ms = new MockDataStore();

            if (Option == "Groceries")
            {
                entities = ms.Groceries;
            }
            if (Option == "Pharmacy")
            {
                entities = ms.Pharmacies;
            }
            if (Option == "Covid 19 Screening")
            {
                entities = ms.Covid19testsites;
            }

            //Bing Image Search API
            //SearchResult result = BingImageSearch(Option);
            //deserialize the JSON response from the Bing Image Search API
            //dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(result.jsonResult);
            //var val = jsonObj["value"];

            //SearchResult result1 = BingLocalSearch($"{ Option} near {searchQuery.Destination}");
            //dynamic jsonObj1 = Newtonsoft.Json.JsonConvert.DeserializeObject(result1.jsonResult);
            //var val1 = jsonObj1["value"];



            // Filling the hotels results manually just for demo purposes
            //for (int i = 1; i <= 5; i++)
            //{
            //    var random = new Random(i);
            //    Hotel hotel = new Hotel()
            //    {
            //        Name = $"{searchQuery.Destination} Hotel {i}",
            //        Location = searchQuery.Destination,
            //        Timings = random.Next(1, 5),
            //        NumberOfReviews = random.Next(0, 5000),
            //        PriceStarting = random.Next(80, 450),
            //        Image = jsonObj["value"][i - 1]["contentUrl"]   // $"https://placehold.imgix.net/~text?txtsize=35&txt={Option}+{i}&w=500&h=260"
            //};

            //    hotels.Add(hotel);
            //}

            //hotels.Sort((h1, h2) => h1.PriceStarting.CompareTo(h2.PriceStarting));

            return(entities);
        }
        public void ProfileSaveDoesNotSerializeContext()
        {
            var dataStore   = new MockDataStore();
            var profilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.Instance.ProfileFile);
            var profile     = new AzureSMProfile(profilePath);

            AzureSession.Instance.DataStore = dataStore;
            var tenant      = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name            = "testCloud",
                ActiveDirectory = new Uri("http://contoso.com")
            };
            var account = new AzureAccount
            {
                Id   = "*****@*****.**",
                Type = AzureAccount.AccountType.User,
            };

            account.SetTenants(tenant);
            var sub = new AzureSubscription
            {
                Id   = new Guid().ToString(),
                Name = "Contoso Test Subscription",
            };

            sub.SetAccount(account.Id);
            sub.SetEnvironment(environment.Name);
            sub.SetTenant(tenant);
            profile.EnvironmentTable[environment.Name] = environment;
            profile.AccountTable[account.Id]           = account;
            profile.SubscriptionTable[sub.GetId()]     = sub;

            profile.Save();

            var    profileFile     = profile.ProfilePath;
            string profileContents = dataStore.ReadFileAsText(profileFile);
            var    readProfile     = JsonConvert.DeserializeObject <Dictionary <string, object> >(profileContents);

            Assert.False(readProfile.ContainsKey("DefaultContext"));
            AzureSMProfile parsedProfile = new AzureSMProfile();
            var            serializer    = new JsonProfileSerializer();

            Assert.True(serializer.Deserialize(profileContents, parsedProfile));
            Assert.NotNull(parsedProfile);
            Assert.NotNull(parsedProfile.Environments);
            Assert.True(parsedProfile.EnvironmentTable.ContainsKey(environment.Name));
            Assert.NotNull(parsedProfile.Accounts);
            Assert.True(parsedProfile.AccountTable.ContainsKey(account.Id));
            Assert.NotNull(parsedProfile.Subscriptions);
            Assert.True(parsedProfile.SubscriptionTable.ContainsKey(sub.GetId()));
        }
Example #27
0
 public ItemsViewModel()
 {
     Title            = "Browse";
     Items            = new ObservableCollection <Item>();
     LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
     ds = new MockDataStore();
     MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
     {
         var newItem = item as Item;
         Items.Add(newItem);
         await ds.AddItemAsync(newItem);
     });
 }
Example #28
0
        public void TestSameHasTradeID()
        {
            //Arrange
            MockDataStore mockDataStore = new MockDataStore();
            List <Trade>  trades        = mockDataStore.GetMockedDoublicatedTradeIdList();

            //Act
            TradeLogicHelper tradeLogic       = new TradeLogicHelper();
            bool             doesntHaveSameId = tradeLogic.CheckNotSameTradeId(trades);

            //Assert
            Assert.IsTrue(!doesntHaveSameId);
        }
Example #29
0
        private void FillListView()
        {
            MockDataStore store = new MockDataStore();
            var           items = store.GetItemsAsync().Result;

            listView1.Items.Clear();
            foreach (var item in items)
            {
                var displayItems = new string[] { item.Text, item.Description };
                var lvItem       = new ListViewItem(displayItems);
                listView1.Items.Add(lvItem);
            }
        }
        public void ProfileSaveDoesNotSerializeContext()
        {
            var dataStore      = new MockDataStore();
            var currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));

            AzureSession.DataStore = dataStore;
            var client      = new ProfileClient(currentProfile);
            var tenant      = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name      = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id         = "*****@*****.**",
                Type       = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenant } }
            };
            var sub = new AzureSubscription
            {
                Account     = account.Id,
                Environment = environment.Name,
                Id          = new Guid(),
                Name        = "Contoso Test Subscription",
                Properties  = { { AzureSubscription.Property.Tenants, tenant } }
            };

            client.AddOrSetEnvironment(environment);
            client.AddOrSetAccount(account);
            client.AddOrSetSubscription(sub);

            currentProfile.Save();

            var    profileFile     = currentProfile.ProfilePath;
            string profileContents = dataStore.ReadFileAsText(profileFile);
            var    readProfile     = JsonConvert.DeserializeObject <Dictionary <string, object> >(profileContents);

            Assert.False(readProfile.ContainsKey("Context"));
            AzureProfile parsedProfile = new AzureProfile();
            var          serializer    = new JsonProfileSerializer();

            Assert.True(serializer.Deserialize(profileContents, parsedProfile));
            Assert.NotNull(parsedProfile);
            Assert.NotNull(parsedProfile.Environments);
            Assert.True(parsedProfile.Environments.ContainsKey(environment.Name));
            Assert.NotNull(parsedProfile.Accounts);
            Assert.True(parsedProfile.Accounts.ContainsKey(account.Id));
            Assert.NotNull(parsedProfile.Subscriptions);
            Assert.True(parsedProfile.Subscriptions.ContainsKey(sub.Id));
        }