public void TestDeleteChapSettings() { var iscsiServers = TestUtilities.GetIscsiServers( this.Client, this.ResourceGroupName, this.ManagerName); Assert.True(iscsiServers != null && iscsiServers.Count() > 0, "No iscsiserver found in the given manager:" + this.ManagerName); var iscsiServer = iscsiServers.FirstOrDefault(); var chapSettings = new ChapSettings( this.Client, this.ResourceGroupName, this.ManagerName, TestConstants.DefaultChapSettingNameForDelete); chapSettings.Initialize(); var chapSettingsCreated = chapSettings.CreateOrUpdate(iscsiServer.Name); var chapSettingsGet = TestUtilities.GetChapSettings( chapSettings.Name, iscsiServer.Name, this.Client, this.ResourceGroupName, this.ManagerName); var chapSettingsList = iscsiServer.GetChapSettings(iscsiServer.Name); Assert.True(chapSettingsList != null && chapSettingsList.Any(), "No chapsettings found"); var chapSettingToDelete = chapSettingsList.FirstOrDefault(cs => cs.Name.Equals( chapSettings.Name, StringComparison.CurrentCultureIgnoreCase)); Assert.True(chapSettingToDelete != null, "ChapSetting to delete not found"); // Delete the chap settings TestUtilities.DeleteChapSettings( chapSettingToDelete.Name, iscsiServer.Name, this.Client, this.ResourceGroupName, this.ManagerName); }
public void TestCreateOrUpdateChapSettings() { var iscsiServers = TestUtilities.GetIscsiServers( this.Client, this.ResourceGroupName, this.ManagerName); Assert.True(iscsiServers != null && iscsiServers.Count() > 0, "No iscsiserver found in the given manager:" + this.ManagerName); var iscsiServer = iscsiServers.FirstOrDefault(); var chapSettings = new ChapSettings( this.Client, this.ResourceGroupName, this.ManagerName, TestConstants.DefaultChapSettingName); chapSettings.Initialize(); var chapSettingsCreated = chapSettings.CreateOrUpdate(iscsiServer.Name); var chapSettingsAfterGet = TestUtilities.GetChapSettings( chapSettings.Name, iscsiServer.Name, this.Client, this.ResourceGroupName, this.ManagerName); Assert.True(chapSettingsAfterGet.Name.Equals( chapSettings.Name, StringComparison.CurrentCultureIgnoreCase), "ChapSettings created but not found"); Assert.True(string.IsNullOrWhiteSpace(iscsiServer.ChapId), "ChapId already set"); // Update the iscsiserver iscsiServer.ChapId = chapSettingsAfterGet.Id; var iscsiServerAfterUpdate = iscsiServer.CreateOrUpdate(iscsiServer.Name); Assert.True( iscsiServerAfterUpdate.ChapId.Equals( chapSettingsAfterGet.Id, StringComparison.CurrentCultureIgnoreCase), "ChapId failed to be set on IscsiServer"); }