コード例 #1
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                var filters = new OrganizationActivityFilters
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 0,
                    Done      = ActivityDone.Done,
                };

                await client.GetActivities(123, filters);

                Received.InOrder(async() =>
                {
                    await connection.GetAll <DealActivity>(
                        Arg.Is <Uri>(u => u.ToString() == "organizations/123/activities"),
                        Arg.Is <Dictionary <string, string> >(d => d.Count == 2 &&
                                                              d["id"] == "123" &&
                                                              d["done"] == "1"),
                        Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                            o.PageCount == 1 &&
                                            o.StartPage == 0));
                });
            }
コード例 #2
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCurrent(null));
            }
コード例 #3
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                var filters = new OrganizationSearchFilters
                {
                    ExactMatch = true,
                    PageSize   = 1,
                    PageCount  = 1,
                    StartPage  = 0,
                };

                await client.Search("name", filters);

                Received.InOrder(async() =>
                {
                    await connection.SearchAll <SearchResult <SimpleOrganization> >(Arg.Is <Uri>(u => u.ToString() == "organizations/search"),
                                                                                    Arg.Is <Dictionary <string, string> >(d => d.Count == 2 &&
                                                                                                                          d["term"] == "name" &&
                                                                                                                          d["exact_match"] == "True"),
                                                                                    Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                                                                                        o.PageCount == 1 &&
                                                                                                        o.StartPage == 0));
                });
            }
コード例 #4
0
        async Task SubmitForm()
        {
            saved = false;
            error = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(Id))
                {
                    await OrganizationsClient.CreateOrganizationAsync(organization);

                    NavigationManager.NavigateTo("/organizations");
                }
                else
                {
                    await OrganizationsClient.UpdateOrganizationAsync(Id, organization);

                    saved = true;
                }
            }

            /* catch (ApiException exc)
             * {
             * }
             * catch (HttpRequestException exc)
             * {
             * } */
            catch (Exception exc)
            {
                saved = false;
                error = exc.Message;
            }
        }
コード例 #5
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                var filters = new OrganizationFilters
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 0,
                };

                await client.GetAllForUserId(123, filters);

                Received.InOrder(async() =>
                {
                    await connection.GetAll <Organization>(
                        Arg.Is <Uri>(u => u.ToString() == "organizations"),
                        Arg.Is <Dictionary <string, string> >(d => d.Count == 1 &&
                                                              d["user_id"] == "123"),
                        Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                            o.PageCount == 1 &&
                                            o.StartPage == 0));
                });
            }
コード例 #6
0
        private async Task OnInitalize()
        {
            if (!string.IsNullOrEmpty(Id))
            {
                try
                {
                    organization = await OrganizationsClient.GetOrganizationAsync(Id);

                    if (organization.Address == null)
                    {
                        organization.Address = new Address();
                    }
                }

                /* catch (ApiException exc)
                 * {
                 * }
                 * catch (HttpRequestException exc)
                 * {
                 * } */
                catch (Exception exc)
                {
                    await JSHelpers.Alert(exc.Message);
                }
            }
            else
            {
                organization = new Organization()
                {
                    Address = new Address()
                };
            }
        }
コード例 #7
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new OrganizationsClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Get(""));
            }
コード例 #8
0
            public async Task EnsuresSearchTermIsMoreThan2Characters()
            {
                var client = new OrganizationsClient(Substitute.For <IApiConnection>());

                var exception = await Assert.ThrowsAsync <ArgumentException>(() => client.Search("p", OrganizationSearchFilters.None));

                Assert.Equal("The search term must have at least 2 characters (Parameter 'term')", exception.Message);
            }
コード例 #9
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new OrganizationsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Hook.Edit(null, 12345678, new EditOrganizationHook()));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Hook.Edit("name", 12345678, null));
            }
コード例 #10
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                client.Hook.Delete("org", 12345678);

                connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "orgs/org/hooks/12345678"));
            }
コード例 #11
0
            public void EnsuresNonEmptyArguments()
            {
                var client = new OrganizationsClient(Substitute.For <IApiConnection>());
                var config = new Dictionary <string, string> {
                    { "url", "" }
                };

                Assert.ThrowsAsync <ArgumentException>(() => client.Hook.Create("", new NewOrganizationHook("name", config)));
            }
コード例 #12
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await client.Get("orgName");

                connection.Received().Get<Organization>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgName"));
            }
コード例 #13
0
            public void RequestsTheCorrectUrl()
            {
                var client = Substitute.For<IApiConnection>();
                var orgs = new OrganizationsClient(client);

                orgs.GetAllForCurrent();

                client.Received().GetAll<Organization>(Arg.Is<Uri>(u => u.ToString() == "user/orgs"));
            }
コード例 #14
0
ファイル: ManagerPage.razor.cs プロジェクト: lulzzz/showroom
        private async Task OnInitialize()
        {
            userProfile = await IdentityService.GetUserProfileAsync();

            if (!string.IsNullOrEmpty(Id))
            {
                if (Guid.TryParse(Id, out var id))
                {
                    try
                    {
                        manager = Mapper.Map <UpdateManagerProfile>(await ManagersClient.GetManagerAsync(id));
                        if (manager.Address == null)
                        {
                            manager.Address = new Address();
                        }
                    }

                    /* catch (ApiException exc)
                     * {
                     * }
                     * catch (HttpRequestException exc)
                     * {
                     * } */
                    catch (Exception exc)
                    {
                        await JSHelpers.Alert(exc.Message);
                    }
                }
                else
                {
                    // Handle expected guid
                }
            }
            else
            {
                manager = new AddManagerProfile()
                {
                    Address = new Address()
                };
            }

            try
            {
                organizations = await OrganizationsClient.GetOrganizationsAsync();
            }

            /* catch (ApiException exc)
             * {
             * }
             * catch (HttpRequestException exc)
             * {
             * } */
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }
        }
コード例 #15
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await client.Get("orgName");

                connection.Received().Get <Organization>(Arg.Is <Uri>(u => u.ToString() == "orgs/orgName"));
            }
コード例 #16
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await client.GetAllForCurrent();

                connection.Received().GetAll <Organization>(Arg.Is <Uri>(u => u.ToString() == "user/orgs"), Args.ApiOptions);
            }
コード例 #17
0
            public void RequestsTheCorrectUrl()
            {
                var client = Substitute.For <IApiConnection>();
                var orgs   = new OrganizationsClient(client);

                orgs.GetAllForCurrent();

                client.Received().GetAll <Organization>(Arg.Is <Uri>(u => u.ToString() == "user/orgs"));
            }
コード例 #18
0
            public void DeletesCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                client.Delete(123);

                connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "organizations/123"));
            }
コード例 #19
0
            public void RequestsCorrectUrl()
            {
                var client     = Substitute.For <IApiConnection>();
                var orgsClient = new OrganizationsClient(client);

                orgsClient.Get("orgName");

                client.Received().Get <Organization>(Arg.Is <Uri>(u => u.ToString() == "orgs/orgName"), null);
            }
コード例 #20
0
            public void RequestsTheCorrectUrl()
            {
                var client = Substitute.For <IApiConnection>();
                var orgs   = new OrganizationsClient(client);

                orgs.Update("initrode", new OrganizationUpdate());

                client.Received().Patch <Organization>(Arg.Is <Uri>(u => u.ToString() == "orgs/initrode"), Args.OrganizationUpdate);
            }
コード例 #21
0
            public void RequestsCorrectUrl()
            {
                var client = Substitute.For<IApiConnection>();
                var orgsClient = new OrganizationsClient(client);

                orgsClient.Get("orgName");

                client.Received().Get<Organization>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgName"), null);
            }
コード例 #22
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await client.GetAll("username");

                connection.Received().GetAll<Organization>(Arg.Is<Uri>(u => u.ToString() == "users/username/orgs"), Args.ApiOptions);
            }
コード例 #23
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await client.Update("initrode", new OrganizationUpdate());

                connection.Received().Patch <Organization>(Arg.Is <Uri>(u => u.ToString() == "orgs/initrode"), Args.OrganizationUpdate);
            }
コード例 #24
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);
                var hook       = new EditOrganizationHook();

                client.Hook.Edit("org", 12345678, hook);

                connection.Received().Patch <OrganizationHook>(Arg.Is <Uri>(u => u.ToString() == "orgs/org/hooks/12345678"), hook);
            }
コード例 #25
0
            public void PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                client.AddFollower(1, 2);

                connection.Received().Post <OrganizationFollower>(Arg.Is <Uri>(u => u.ToString() == "organizations/1/followers"),
                                                                  Arg.Is <object>(o => o.ToString() == new { user_id = 2 }.ToString()));
            }
コード例 #26
0
 /// <summary>Snippet for SetIamPolicy</summary>
 public void SetIamPolicy()
 {
     // Snippet: SetIamPolicy(string, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     string resource = "a/wildcard/resource";
     // Make the request
     Policy response = organizationsClient.SetIamPolicy(resource);
     // End snippet
 }
コード例 #27
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(null, new OrganizationUpdate()));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("org", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Update("", new OrganizationUpdate()));
            }
コード例 #28
0
            public async Task RequestsTheCorrectUrlWithRequestParameter()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                var request = new OrganizationRequest(1);

                await client.GetAll(request);

                connection.Received().GetAll <Organization>(Arg.Is <Uri>(u => u.ToString() == "organizations?since=1"));
            }
コード例 #29
0
 /// <summary>Snippet for SetIamPolicy</summary>
 public void SetIamPolicyResourceNames()
 {
     // Snippet: SetIamPolicy(IResourceName, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     IResourceName resource = new UnparsedResourceName("a/wildcard/resource");
     // Make the request
     Policy response = organizationsClient.SetIamPolicy(resource);
     // End snippet
 }
コード例 #30
0
 /// <summary>Snippet for GetOrganization</summary>
 public void GetOrganizationResourceNames()
 {
     // Snippet: GetOrganization(OrganizationName, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     OrganizationName name = OrganizationName.FromOrganization("[ORGANIZATION]");
     // Make the request
     Organization response = organizationsClient.GetOrganization(name);
     // End snippet
 }
コード例 #31
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new OrganizationsClient(Substitute.For <IApiConnection>());

                var config = new Dictionary <string, string> {
                    { "config", "" }
                };
                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Hook.Create(null, new NewOrganizationHook("name", config)));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Hook.Create("name", null));
            }
コード例 #32
0
 /// <summary>Snippet for GetOrganization</summary>
 public void GetOrganization()
 {
     // Snippet: GetOrganization(string, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     string name = "organizations/[ORGANIZATION]";
     // Make the request
     Organization response = organizationsClient.GetOrganization(name);
     // End snippet
 }
コード例 #33
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("username", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", ApiOptions.None));
            }
コード例 #34
0
            public void PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                var newOrganization = new NewOrganization("name");

                client.Create(newOrganization);

                connection.Received().Post <Organization>(Arg.Is <Uri>(u => u.ToString() == "organizations"),
                                                          Arg.Is <NewOrganization>(d => d.Name == "name"));
            }
コード例 #35
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await client.Get(123);

                Received.InOrder(async() =>
                {
                    await connection.Get <Organization>(Arg.Is <Uri>(u => u.ToString() == "organizations/123"));
                });
            }
コード例 #36
0
 /// <summary>Snippet for TestIamPermissions</summary>
 public void TestIamPermissionsResourceNames()
 {
     // Snippet: TestIamPermissions(IResourceName, IEnumerable<string>, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     IResourceName        resource    = new UnparsedResourceName("a/wildcard/resource");
     IEnumerable <string> permissions = new string[] { "", };
     // Make the request
     TestIamPermissionsResponse response = organizationsClient.TestIamPermissions(resource, permissions);
     // End snippet
 }
コード例 #37
0
            public async Task RequestsTheCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                await client.GetAll("username", options);

                connection.Received().GetAll<Organization>(Arg.Is<Uri>(u => u.ToString() == "users/username/orgs"), options);
            }
コード例 #38
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, new OrganizationUpdate()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("org", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", new OrganizationUpdate()));
            }
コード例 #39
0
            public void EnsuresNonNullArguments()
            {
                var orgs = new OrganizationsClient(Substitute.For<IApiConnection>());

                Assert.Throws<ArgumentNullException>(() => orgs.GetAll(null));
            }
コード例 #40
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await client.Update("initrode", new OrganizationUpdate());

                connection.Received().Patch<Organization>(Arg.Is<Uri>(u => u.ToString() == "orgs/initrode"), Args.OrganizationUpdate);
            }
コード例 #41
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll((OrganizationRequest)null));
            }
コード例 #42
0
            public async Task RequestsTheCorrectUrlWithRequestParameter()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                var request =  new OrganizationRequest(1);

                await client.GetAll(request);

                connection.Received().GetAll<Organization>(Arg.Is<Uri>(u => u.ToString() == "organizations?since=1"));
            }
コード例 #43
0
            public async Task EnsuresNonNullArguments()
            {
                var orgs = new OrganizationsClient(Substitute.For<IApiConnection>());

                AssertEx.Throws<ArgumentNullException>(async () => await orgs.GetAll(null));
            }
コード例 #44
0
            public void RequestsTheCorrectUrl()
            {
                var client = Substitute.For<IApiConnection>();
                var orgs = new OrganizationsClient(client);

                orgs.Update("initrode", new OrganizationUpdate());

                client.Received().Patch<Organization>(Arg.Is<Uri>(u => u.ToString() == "orgs/initrode"), Args.OrganizationUpdate);
            }