Files
openstack-sdk-dotnet/OpenStack/OpenStack.Test/Storage/StorageServiceClientDefinitionTests.cs
Wayne Foley 52ca59f4fa Removed the OpenStack.Common assembly and combined it into a single OpenStack assembly.
Refactored the service location code to be compliant with PCLs.
Converted the Openstack assembly into a PCL, and updated the tests.
As part of the PCL converstion minor tweeks to stirng comparison and use of System.Security were updated.

Implements: blueprint convert-to-pcl-lib
Change-Id: I2091d009c506f6ee183d16a817902dfc341fab5a
2014-04-10 10:25:40 -07:00

71 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenStack.Common;
using OpenStack.Identity;
using OpenStack.Storage;
namespace OpenStack.Test.Storage
{
[TestClass]
public class StorageServiceClientDefinitionTests
{
IOpenStackCredential GetValidCreds()
{
var authId = "12345";
var endpoint = "http://teststorageendpoint.com/v1/1234567890";
var creds = new OpenStackCredential(new Uri(endpoint), "SomeUser", "Password", "SomeTenant");
creds.SetAccessTokenId(authId);
return creds;
}
[TestMethod]
public void CanSupportVersion1()
{
var client = new StorageServiceClientDefinition();
var creds = GetValidCreds();
var catalog =
new OpenStackServiceCatalog
{
new OpenStackServiceDefinition("Object Storage", "Test",
new List<OpenStackServiceEndpoint>()
{
new OpenStackServiceEndpoint("http://someplace.com", "somewhere", "1.0",
"http://www.someplace.com", "http://www.someplace.com")
})
};
creds.SetServiceCatalog(catalog);
Assert.IsTrue(client.IsSupported(creds));
}
[TestMethod]
public void CannotSupportVersion2()
{
var client = new StorageServiceClientDefinition();
var creds = GetValidCreds();
var catalog =
new OpenStackServiceCatalog
{
new OpenStackServiceDefinition("Object Storage", "Test",
new List<OpenStackServiceEndpoint>()
{
new OpenStackServiceEndpoint("http://someplace.com", "somewhere", "2.0.0.0",
"http://www.someplace.com", "http://www.someplace.com")
})
};
creds.SetServiceCatalog(catalog);
Assert.IsFalse(client.IsSupported(creds));
}
[TestMethod]
public void Version1Supported()
{
var client = new StorageServiceClientDefinition();
Assert.IsTrue(client.ListSupportedVersions().Contains("1.0"));
Assert.IsTrue(client.ListSupportedVersions().Contains("1"));
}
}
}