コード例 #1
0
        private static void Main(string[] arguments)
        {
            if (null == arguments)
            {
                Console.WriteLine(FileProvisioningServiceResources.InformationCommandLineArguments);
                return;
            }

            if (Program.NumberArguments > arguments.Length)
            {
                Console.WriteLine(FileProvisioningServiceResources.InformationCommandLineArguments);
                return;
            }

            string argumentBaseAddress = arguments[0];
            Uri    baseAddress         = null;

            if (!Uri.TryCreate(argumentBaseAddress, UriKind.Absolute, out baseAddress))
            {
                Console.WriteLine(FileProvisioningServiceResources.InformationCommandLineArguments);
                return;
            }

            string informationBaseAddress =
                string.Format(
                    CultureInfo.InvariantCulture,
                    FileProvisioningServiceResources.InformationBaseAddressTemplate,
                    argumentBaseAddress);

            Console.WriteLine(informationBaseAddress);

            IMonitor monitor = new ProvisioningAgentMonitor(FileProvisioningServiceResources.PromptTerminate);

            FileProviderBase provider = null;

            try
            {
                provider =
                    new AccessConnectivityEngineFileProviderFactory(
                        arguments[1],
                        monitor)
                    .CreateProvider();
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(baseAddress);

                    string informationStarted =
                        string.Format(
                            CultureInfo.InvariantCulture,
                            FileProvisioningServiceResources.InformationServiceStartedTemplate,
                            argumentBaseAddress);
                    Console.WriteLine(informationStarted);

                    Console.WriteLine(FileProvisioningServiceResources.PromptTerminate);
                    Console.ReadKey(true);
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }
        }
コード例 #2
0
        public void TestLifecycleGroup()
        {
            Uri addressBase = new Uri(WebServiceUnitTest.AddressBase);

            IMonitor monitor = new ConsoleMonitor();

            IAmazonWebServicesIdentityAnchoringBehavior anchoringBehavior =
                new AnchoringByIdentifierBehavior();
            AmazonWebServicesProviderBase provider = new AmazonWebServicesProvider(WebServiceUnitTest.CredentialsProfileName, anchoringBehavior);
            Service webService = null;
            try
            {
                webService = new WebService(monitor, provider);
                webService.Start(addressBase);

                string identifierGroup;
                string identifierGroupExternal;
                string identifierMemberOne;
                string identifierMemberTwo;
                
                Uri resource;

                WebClient client = null;
                try
                {
                    IDictionary<string, object> json;
                    string characters;
                    byte[] bytes;
                    byte[] response;
                    string responseCharacters;
                    IReadOnlyDictionary<string, object> responseJson;
                    Core2EnterpriseUser user;
                    Member member;
                    IReadOnlyCollection<Member> members;

                    client = new WebClient();
                    
                    identifierMemberOne = Guid.NewGuid().ToString();
                    string identifierMemberOneExternal = Guid.NewGuid().ToString();
                    user =
                        new Core2EnterpriseUser()
                        {
                            Identifier = identifierMemberOne,
                            ExternalIdentifier = identifierMemberOneExternal
                        };

                    json = user.ToJson();
                    characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                    bytes = Encoding.UTF8.GetBytes(characters);
                    resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers);
                    client.Headers.Clear();
                    client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                    response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                    responseCharacters = Encoding.UTF8.GetString(response);
                    responseJson =
                        WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                    user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                    identifierMemberOne = user.Identifier;

                    try
                    {
                        member = 
                            new Member()
                            {
                                Value = identifierMemberOne
                            };
                        members =
                            new Member[]
                                {
                                    member
                                };

                        identifierGroup = Guid.NewGuid().ToString();
                        identifierGroupExternal = Guid.NewGuid().ToString();

                        WindowsAzureActiveDirectoryGroup group =
                            new WindowsAzureActiveDirectoryGroup()
                            {
                                Identifier = identifierGroup,
                                ExternalIdentifier = identifierGroupExternal,
                                Members = members
                            };

                        json = group.ToJson();
                        characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                        bytes = Encoding.UTF8.GetBytes(characters);
                        resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeGroups);
                        client.Headers.Clear();
                        client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                        response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                        responseCharacters = Encoding.UTF8.GetString(response);
                        responseJson =
                            WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                        group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson);
                        Assert.IsNotNull(group);
                        Assert.IsNotNull(
                            group
                            .Schemas
                            .SingleOrDefault(
                                (string item) =>
                                    string.Equals(
                                        SchemaIdentifiers.WindowsAzureActiveDirectoryGroup,
                                        item,
                                        StringComparison.Ordinal)));
                        Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier));

                        string identifierGroupAmazon = group.Identifier;

                        try
                        {
                            Assert.IsNotNull(group.Metadata);
                            Assert.IsFalse(string.IsNullOrWhiteSpace(group.Metadata.ResourceType));
                            Assert.IsFalse(string.Equals(identifierGroup, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase));

                            string resourcePath = 
                                string.Format(
                                    CultureInfo.InvariantCulture, 
                                    WebServiceUnitTest.AddressRelativeGroupTemplate, 
                                    identifierGroupAmazon);
                            resource = new Uri(addressBase, resourcePath);

                            response = client.DownloadData(resource);
                            responseCharacters = Encoding.UTF8.GetString(response);
                            responseJson =
                                WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                            group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson);
                            Assert.IsNotNull(group);
                            Assert.IsNotNull(
                                group
                                .Schemas
                                .SingleOrDefault(
                                    (string item) =>
                                        string.Equals(
                                            SchemaIdentifiers.Core2Group,
                                            item,
                                            StringComparison.Ordinal)));
                            Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier));
                            Assert.IsTrue(string.Equals(group.Identifier, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase));

                            Assert.IsFalse(string.IsNullOrWhiteSpace(group.ExternalIdentifier));
                            Assert.IsTrue(string.Equals(group.ExternalIdentifier, identifierGroupExternal, StringComparison.OrdinalIgnoreCase));

                            identifierMemberTwo = Guid.NewGuid().ToString();
                            string identifierMemberTwoExternal = Guid.NewGuid().ToString();
                            user =
                                new Core2EnterpriseUser()
                                {
                                    Identifier = identifierMemberTwo,
                                    ExternalIdentifier = identifierMemberTwoExternal
                                };

                            json = user.ToJson();
                            characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                            bytes = Encoding.UTF8.GetBytes(characters);
                            resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers);
                            client.Headers.Clear();
                            client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                            response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                            responseCharacters = Encoding.UTF8.GetString(response);
                            responseJson =
                                WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                            user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                            identifierMemberTwo = user.Identifier;

                            try
                            {
                                IResourceIdentifier resourceIdentifier =
                                    new ResourceIdentifier()
                                    {
                                        Identifier = identifierGroupAmazon,
                                        SchemaIdentifier = SchemaIdentifiers.WindowsAzureActiveDirectoryGroup
                                    };

                                IPath path = Microsoft.SystemForCrossDomainIdentityManagement.Path.Create(AttributeNames.Members);

                                OperationValue operationValue;
                                PatchOperation operation;
                                IReadOnlyCollection<PatchOperation> operations;
                                PatchRequest2 patch;
                                                                
                                operationValue =
                                    new OperationValue()
                                    {
                                        Value = identifierMemberTwo
                                    };
                                operation =
                                    new PatchOperation()
                                    {
                                        Name = OperationName.Add,
                                        Path = path
                                    };
                                operations =
                                    new PatchOperation[] 
                                        { 
                                            operation 
                                        };
                                operation.AddValue(operationValue);                                
                                
                                patch = new PatchRequest2();
                                patch.AddOperation(operation);
                                json = patch.ToJson();
                                characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                                bytes = Encoding.UTF8.GetBytes(characters);
                                resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon);
                                resource = new Uri(addressBase, resourcePath);
                                client.Headers.Clear();
                                client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                                response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes);

                                operationValue =
                                   new OperationValue()
                                   {
                                       Value = identifierMemberTwo
                                   };
                                operation =
                                    new PatchOperation()
                                    {
                                        Name = OperationName.Remove,
                                        Path = path
                                    };
                                operations =
                                    new PatchOperation[] 
                                        { 
                                            operation 
                                        };
                                operation.AddValue(operationValue);

                                patch = new PatchRequest2();
                                patch.AddOperation(operation);
                                json = patch.ToJson();
                                characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                                bytes = Encoding.UTF8.GetBytes(characters);
                                resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon);
                                resource = new Uri(addressBase, resourcePath);
                                client.Headers.Clear();
                                client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                                response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes);

                                operationValue =
                                   new OperationValue()
                                   {
                                       Value = identifierMemberOne
                                   };
                                operation =
                                    new PatchOperation()
                                    {
                                        Name = OperationName.Remove,
                                        Path = path
                                    };
                                operations =
                                    new PatchOperation[] 
                                        { 
                                            operation 
                                        };
                                operation.AddValue(operationValue);

                                patch = new PatchRequest2();
                                patch.AddOperation(operation);
                                json = patch.ToJson();
                                characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                                bytes = Encoding.UTF8.GetBytes(characters);
                                resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon);
                                resource = new Uri(addressBase, resourcePath);
                                client.Headers.Clear();
                                client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                                response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes);
                            }
                            finally
                            {
                                resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberTwo);
                                resource = new Uri(addressBase, resourcePath);
                                bytes = new byte[0];
                                client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                            }
                        }
                        finally
                        {
                            string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon);
                            resource = new Uri(addressBase, resourcePath);
                            bytes = new byte[0];
                            client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                        }
                    }
                    finally
                    {
                        string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberOne);
                        resource = new Uri(addressBase, resourcePath);
                        bytes = new byte[0];
                        client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                    }
                }
                finally
                {
                    if (client != null)
                    {
                        client.Dispose();
                        client = null;
                    }
                }
            }
            finally
            {
                if (webService != null)
                {
                    webService.Dispose();
                    webService = null;
                }
            }
        }
        public void TestCreateUser()
        {
            Uri resourceBase  = new Uri(WebServiceUnitTest.AddressBase);
            Uri resourceUsers = new Uri(WebServiceUnitTest.AddressRelativeUsers, UriKind.Relative);

            IMonitor monitor  = new ConsoleMonitor();
            string   fileName = CommaDelimitedFileUnitTest.ComposeFileName();

            FileProviderBase provider = null;

            try
            {
                provider = new AccessConnectivityEngineFileProviderFactory(fileName, monitor).CreateProvider();
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(resourceBase);

                    IDictionary <string, object> json = SampleComposer.Instance.ComposeUserResource().ToJson();
                    string characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                    byte[] bytes      = Encoding.UTF8.GetBytes(characters);

                    Uri resource = new Uri(resourceBase, resourceUsers);

                    WebClient client = null;
                    try
                    {
                        client = new WebClient();
                        client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                        byte[] response           = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                        string responseCharacters = Encoding.UTF8.GetString(response);
                        IReadOnlyDictionary <string, object> responseJson =
                            WebServiceUnitTest.Serializer.Value.Deserialize <Dictionary <string, object> >(responseCharacters);
                        Core2EnterpriseUser user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                        Assert.IsNotNull(user);
                        Assert.IsNotNull(
                            user
                            .Schemas
                            .SingleOrDefault(
                                (string item) =>
                                string.Equals(
                                    SchemaIdentifiers.Core2EnterpriseUser,
                                    item,
                                    StringComparison.Ordinal)));
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier));
                        Assert.IsNotNull(user.Metadata);
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType));

                        string resourcePathValue =
                            string.Concat(WebServiceUnitTest.AddressRelativeUser, user.Identifier);
                        Uri resourcePath = new Uri(resourcePathValue, UriKind.Relative);
                        resource = new Uri(resourceBase, resourcePath);
                        bytes    = new byte[0];
                        client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                    }
                    finally
                    {
                        if (client != null)
                        {
                            client.Dispose();
                            client = null;
                        }
                    }
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }
        }
コード例 #4
0
        public void TestLifecycleUser()
        {
            Uri addressBase = new Uri(WebServiceUnitTest.AddressBase);

            IMonitor monitor = new ConsoleMonitor();
            
            IAmazonWebServicesIdentityAnchoringBehavior anchoringBehavior = 
                new AnchoringByIdentifierBehavior();
            AmazonWebServicesProviderBase provider = new AmazonWebServicesProvider(WebServiceUnitTest.CredentialsProfileName, anchoringBehavior);
            Service webService = null;
            try
            {
                webService = new WebService(monitor, provider);
                webService.Start(addressBase);

                string identifier = Guid.NewGuid().ToString();
                string identifierExternal = Guid.NewGuid().ToString();
                Core2EnterpriseUser user =
                    new Core2EnterpriseUser()
                    {
                        Identifier = identifier,
                        ExternalIdentifier = identifierExternal
                    };
                IDictionary<string, object> json = user.ToJson();
                string characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                byte[] bytes = Encoding.UTF8.GetBytes(characters);

                Uri resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers);

                WebClient client = null;
                try
                {
                    client = new WebClient();
                    client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                    byte[] response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                    string responseCharacters = Encoding.UTF8.GetString(response);
                    IReadOnlyDictionary<string, object> responseJson =
                        WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                    user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                    Assert.IsNotNull(user);
                    Assert.IsNotNull(
                        user
                        .Schemas
                        .SingleOrDefault(
                            (string item) =>
                                string.Equals(
                                    SchemaIdentifiers.Core2EnterpriseUser,
                                    item,
                                    StringComparison.Ordinal)));
                    Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier));

                    string identifierAmazon = user.Identifier;
                    string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierAmazon);
                    resource = new Uri(addressBase, resourcePath);

                    try
                    {
                        Assert.IsNotNull(user.Metadata);
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType));
                        Assert.IsFalse(string.Equals(identifier, identifierAmazon, StringComparison.OrdinalIgnoreCase));

                        response = client.DownloadData(resource);
                        responseCharacters = Encoding.UTF8.GetString(response);
                        responseJson =
                            WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                        user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                        Assert.IsNotNull(user);
                        Assert.IsNotNull(
                            user
                            .Schemas
                            .SingleOrDefault(
                                (string item) =>
                                    string.Equals(
                                        SchemaIdentifiers.Core2EnterpriseUser,
                                        item,
                                        StringComparison.Ordinal)));
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier));
                        Assert.IsTrue(string.Equals(user.Identifier, identifierAmazon, StringComparison.OrdinalIgnoreCase));

                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.ExternalIdentifier));
                        Assert.IsTrue(string.Equals(user.ExternalIdentifier, identifierExternal, StringComparison.OrdinalIgnoreCase));
                    }
                    finally
                    {
                        bytes = new byte[0];
                        client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                    }
                }
                finally
                {
                    if (client != null)
                    {
                        client.Dispose();
                        client = null;
                    }
                }
            }
            finally
            {
                if (webService != null)
                {
                    webService.Dispose();
                    webService = null;
                }
            }
        }
コード例 #5
0
        private static void Main(string[] arguments)
        {
            if (null == arguments)
            {
                Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments);
                return;
            }

            if (Program.NumberArguments > arguments.Length)
            {
                Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments);
                return;
            }

            string argumentBaseAddress = arguments[0];
            Uri baseAddress = null;
            if (!Uri.TryCreate(argumentBaseAddress, UriKind.Absolute, out baseAddress))
            {
                Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments);
                return;
            }

            string informationBaseAddress =
                string.Format(
                    CultureInfo.InvariantCulture,
                    ProvisioningAgentResources.InformationBaseAddressTemplate,
                    argumentBaseAddress);
            Console.WriteLine(informationBaseAddress);

            IMonitor monitor = new ConsoleMonitor();
            FileProviderBase provider = null;
            try
            {
                provider = new FileProvider(arguments[1]);
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(baseAddress);

                    string informationStarted =
                        string.Format(
                            CultureInfo.InvariantCulture,
                            ProvisioningAgentResources.InformationAgentStartedTemplate,
                            argumentBaseAddress);
                    Console.WriteLine(informationStarted);

                    Console.WriteLine(ProvisioningAgentResources.PromptTerminate);
                    Console.ReadKey(true);
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }
        }
コード例 #6
0
        public void TestCreateUser()
        {
            Uri addressBase = new Uri(WebServiceUnitTest.AddressBase);

            IMonitor monitor = new ConsoleMonitor();

            string fileName = CommaDelimitedFileUnitTest.ComposeFileName();

            FileProviderBase provider = null;
            try
            {
                provider = new FileProvider(fileName);
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(addressBase);

                    IDictionary<string, object> json = ProviderTestTemplate<FileProvider>.ComposeUserResource().ToJson();
                    string characters = WebServiceUnitTest.Serializer.Value.Serialize(json);
                    byte[] bytes = Encoding.UTF8.GetBytes(characters);

                    Uri resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers);

                    WebClient client = null;
                    try
                    {
                        client = new WebClient();
                        client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson);
                        byte[] response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes);
                        string responseCharacters = Encoding.UTF8.GetString(response);
                        IReadOnlyDictionary<string, object> responseJson =
                            WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters);
                        Core2EnterpriseUser user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson);
                        Assert.IsNotNull(user);
                        Assert.IsNotNull(
                            user
                            .Schemas
                            .SingleOrDefault(
                                (string item) =>
                                    string.Equals(
                                        SchemaIdentifiers.Core2EnterpriseUser,
                                        item,
                                        StringComparison.Ordinal)));
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier));
                        Assert.IsNotNull(user.Metadata);
                        Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType));

                        string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, user.Identifier);
                        resource = new Uri(addressBase, resourcePath);
                        bytes = new byte[0];
                        client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes);
                    }
                    finally
                    {
                        if (client != null)
                        {
                            client.Dispose();
                            client = null;
                        }
                    }
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }
            
        }
コード例 #7
0
        public void TestRetrieveGroup()
        {
            Uri addressBase = new Uri(WebServiceUnitTest.AddressBase);

            IMonitor monitor = new ConsoleMonitor();

            string fileName = CommaDelimitedFileUnitTest.ComposeFileName();

            FileProviderBase provider = null;
            try
            {
                provider = new FileProvider(fileName);
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(addressBase);

                    Guid groupIdentifier = Guid.NewGuid();
                    string resourceRelative =
                        string.Format(
                            CultureInfo.InvariantCulture,
                            WebServiceUnitTest.AddressRelativeGroupTemplate,
                            groupIdentifier);
                    Uri resource = new Uri(addressBase, resourceRelative);

                    HttpWebResponse response = null;

                    WebClient client = null;
                    try
                    {
                        client = new WebClient();
                        try
                        {
                            client.DownloadData(resource);
                        }
                        catch (WebException exception)
                        {
                            response = exception.Response as HttpWebResponse;
                        }
                    }
                    finally
                    {
                        if (client != null)
                        {
                            client.Dispose();
                            client = null;
                        }
                    }

                    Assert.IsNotNull(response);
                    Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }

        }
コード例 #8
0
        public void TestRetrieveGroup()
        {
            Uri resourceBase = new Uri(WebServiceUnitTest.AddressBase);

            IMonitor monitor = new ConsoleMonitor();

            string fileName = CommaDelimitedFileUnitTest.ComposeFileName();

            FileProviderBase provider = null;

            try
            {
                provider = new AccessConnectivityEngineFileProviderFactory(fileName, monitor).CreateProvider();
                Service webService = null;
                try
                {
                    webService = new WebService(monitor, provider);
                    webService.Start(resourceBase);

                    Guid   groupIdentifier       = Guid.NewGuid();
                    string resourceRelativeValue =
                        string.Format(
                            CultureInfo.InvariantCulture,
                            WebServiceUnitTest.AddressRelativeGroupTemplate,
                            groupIdentifier);
                    Uri resourceRelative = new Uri(resourceRelativeValue, UriKind.Relative);
                    Uri resource         = new Uri(resourceBase, resourceRelative);

                    HttpWebResponse response = null;

                    WebClient client = null;
                    try
                    {
                        client = new WebClient();
                        try
                        {
                            client.DownloadData(resource);
                        }
                        catch (WebException exception)
                        {
                            response = exception.Response as HttpWebResponse;
                        }
                    }
                    finally
                    {
                        if (client != null)
                        {
                            client.Dispose();
                            client = null;
                        }
                    }

                    Assert.IsNotNull(response);
                    Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
                }
                finally
                {
                    if (webService != null)
                    {
                        webService.Dispose();
                        webService = null;
                    }
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                    provider = null;
                }
            }
        }