Esempio n. 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));
                });
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new OrganizationsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCurrent(null));
            }
Esempio n. 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));
                });
            }
Esempio n. 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;
            }
        }
            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));
                });
            }
Esempio n. 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()
                };
            }
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new OrganizationsClient(Substitute.For<IApiConnection>());

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.Get(""));
            }
Esempio n. 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);
            }
Esempio n. 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));
            }
Esempio n. 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"));
            }
Esempio n. 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)));
            }
            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"));
            }
            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"));
            }
Esempio n. 14
0
        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);
            }
        }
            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"));
            }
            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);
            }
Esempio n. 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"));
            }
            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"));
            }
Esempio n. 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);
            }
Esempio n. 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);
            }
            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);
            }
            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);
            }
            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);
            }
Esempio n. 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);
            }
Esempio n. 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()));
            }
Esempio n. 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
 }
            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()));
            }
            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"));
            }
Esempio n. 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
 }
Esempio n. 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
 }
Esempio n. 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));
            }
Esempio n. 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
 }
            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));
            }
            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"));
            }
            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"));
                });
            }
Esempio n. 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
 }
            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);
            }
            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()));
            }
            public void EnsuresNonNullArguments()
            {
                var orgs = new OrganizationsClient(Substitute.For<IApiConnection>());

                Assert.Throws<ArgumentNullException>(() => orgs.GetAll(null));
            }
            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);
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new OrganizationsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll((OrganizationRequest)null));
            }
            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"));
            }
            public async Task EnsuresNonNullArguments()
            {
                var orgs = new OrganizationsClient(Substitute.For<IApiConnection>());

                AssertEx.Throws<ArgumentNullException>(async () => await orgs.GetAll(null));
            }
            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);
            }