Files
openstack-sdk-dotnet/Openstack/Openstack.Test/Storage/StorageServiceClientDefinitionTests.cs
Wayne Foley 23fdb90c2b Adding the initial code base for this repo
Change-Id: Ie3c70c76e0a96978383d2524e8af9a0cc04bd6a2
2014-03-21 12:54:41 -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".ConvertToSecureString(), "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",
new Uri("http://someplace.com"), new Uri("http://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",
new Uri("http://someplace.com"), new Uri("http://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"));
}
}
}