public void TestInitialize()
 {
     _shimContext   = ShimsContext.Create();
     _testEntity    = new GetTemplatesXML();
     _privateObject = new PrivateObject(_testEntity);
 }
Example #2
0
        private void SetupShims()
        {
            shimsContext = ShimsContext.Create();
            SetupVariables();

            ShimSqlConnection.ConstructorString             = (_, __) => new ShimSqlConnection();
            ShimSqlConnection.AllInstances.Open             = _ => { };
            ShimSqlConnection.AllInstances.Close            = _ => { };
            ShimSqlConnection.AllInstances.BeginTransaction = _ => transaction;
            ShimDbTransaction.AllInstances.Dispose          = _ => { };
            ShimSqlConnection.AllInstances.CreateCommand    = _ => new SqlCommand();
            ShimSqlCommand.AllInstances.ExecuteNonQuery     = _ => DummyInt;
            ShimSqlCommand.AllInstances.ExecuteReader       = _ => dataReader;
            ShimComponent.AllInstances.Dispose = _ => { };
            ShimSqlCommand.AllInstances.TransactionSetSqlTransaction = (_, __) => { };
            ShimSPDatabase.AllInstances.DatabaseConnectionStringGet  = _ => DummyString;
            ShimGridGanttSettings.ConstructorSPList = (_, __) => new ShimGridGanttSettings();
            ShimHttpUtility.HtmlEncodeString        = input => input;
            ShimSPSite.ConstructorString            = (_, __) => new ShimSPSite();
            ShimSPSite.ConstructorGuid                                          = (_, __) => new ShimSPSite();
            ShimSPSite.ConstructorGuidSPUserToken                               = (_, _1, _2) => new ShimSPSite();
            ShimSPSite.AllInstances.OpenWeb                                     = _ => spWeb;
            ShimSPSite.AllInstances.OpenWebString                               = (_, __) => spWeb;
            ShimSPSite.AllInstances.OpenWebGuid                                 = (_, __) => spWeb;
            ShimSPSite.AllInstances.Dispose                                     = _ => { };
            ShimSPWeb.AllInstances.Dispose                                      = _ => { };
            ShimCoreFunctions.getLockedWebSPWeb                                 = _ => guid;
            ShimCoreFunctions.getConfigSettingSPWebString                       = (_, __) => bool.FalseString;
            ShimCoreFunctions.getListSettingStringSPList                        = (_, __) => DummyString;
            ShimCoreFunctions.getConnectionStringGuid                           = _ => DummyString;
            ShimCoreFunctions.getLockConfigSettingSPWebStringBoolean            = (_1, _2, _3) => DummyString;
            ShimSPList.AllInstances.GetItemsSPQuery                             = (_, __) => spListItemCollection;
            ShimSPPersistedObject.AllInstances.IdGet                            = _ => guid;
            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = codeToRun => codeToRun();
            ShimUnsecuredLayoutsPageBase.AllInstances.SiteGet                   = _ => spSite;
            ShimUnsecuredLayoutsPageBase.AllInstances.WebGet                    = _ => spWeb;
            ShimAct.ConstructorSPWeb           = (_, __) => new ShimAct();
            ShimSPContext.CurrentGet           = () => new ShimSPContext();
            ShimSPContext.AllInstances.WebGet  = _ => spWeb;
            ShimSPContext.AllInstances.SiteGet = _ => spSite;
            ShimSPFieldLookupValueCollection.ConstructorString = (_, __) => new ShimSPFieldLookupValueCollection();
            ShimSPFieldLookupValue.ConstructorString           = (_, __) => new ShimSPFieldLookupValue();
            ShimSPFieldLookupValue.AllInstances.LookupIdGet    = _ => DummyInt;
            ShimDisabledItemEventScope.Constructor             = _ => new ShimDisabledItemEventScope();
            ShimDisabledItemEventScope.AllInstances.Dispose    = _ => { };
            ShimSPUserCollection.AllInstances.GetByIDInt32     = (_, __) => spUser;
            ShimSPUserCollection.AllInstances.ItemGetString    = (_, __) => spUser;
            ShimSPSiteDataQuery.Constructor            = _ => new ShimSPSiteDataQuery();
            ShimPage.AllInstances.ResponseGet          = _ => new ShimHttpResponse();
            ShimPage.AllInstances.RequestGet           = _ => new ShimHttpRequest();
            ShimHttpRequest.AllInstances.ItemGetString = (_, key) =>
            {
                if (request.ContainsKey(key))
                {
                    return(request[key]);
                }
                return(DummyString);
            };
            ShimSharedFunctions.canUserImpersonateStringStringSPWebStringOut =
                (string curuser, string iuser, SPWeb web, out string resName) =>
            {
                resName = DummyString;
                return(true);
            };
            ShimHttpResponse.AllInstances.ExpiresSetInt32 = (_, __) => { };
            ShimHttpResponse.AllInstances.CacheGet        = _ => new ShimHttpCachePolicy();
            ShimHttpCachePolicy.AllInstances.SetCacheabilityHttpCacheability = (_, __) => { };
            ShimSPAdministrationWebApplication.LocalGet = () => new ShimSPAdministrationWebApplication();
            ShimSPWebApplication.AllInstances.OutboundMailServiceInstanceGet = _ => new ShimSPOutboundMailServiceInstance();
            ShimSPServiceInstance.AllInstances.ServerGet = _ => new ShimSPServer();
            ShimSPPersistedObject.AllInstances.NameGet   = _ => DummyString;
        }
        public void GetMatchingTaxaTest()
        {
            using (ShimsContext.Create())
            {
                FilterController      filterController;
                JsonNetResult         result;
                JsonModel             jsonResult;
                List <TaxonViewModel> taxaListResult;
                String strClipboard;

                // Test get data using RowDelimiter.ReturnLinefeed
                filterController = new FilterController();
                strClipboard     = "1" + Environment.NewLine + "2" + Environment.NewLine + "4";
                result           = filterController.GetMatchingTaxa(strClipboard, RowDelimiter.ReturnLinefeed);
                jsonResult       = (JsonModel)result.Data;
                taxaListResult   = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 3);
                Assert.IsTrue(taxaListResult.Count == 3);
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 1));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 2));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 4));


                // Test get data using RowDelimiter.Semicolon
                strClipboard   = "1;2;4";
                result         = filterController.GetMatchingTaxa(strClipboard, RowDelimiter.Semicolon);
                jsonResult     = (JsonModel)result.Data;
                taxaListResult = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 3);
                Assert.IsTrue(taxaListResult.Count == 3);
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 1));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 2));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 4));



                // Test get data using RowDelimiter.Tab
                strClipboard   = "1\t2\t4";
                result         = filterController.GetMatchingTaxa(strClipboard, RowDelimiter.Tab);
                jsonResult     = (JsonModel)result.Data;
                taxaListResult = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 3);
                Assert.IsTrue(taxaListResult.Count == 3);
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 1));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 2));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 4));


                // Test get data using RowDelimiter.Tab
                strClipboard   = "1|2|4";
                result         = filterController.GetMatchingTaxa(strClipboard, RowDelimiter.VerticalBar);
                jsonResult     = (JsonModel)result.Data;
                taxaListResult = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 3);
                Assert.IsTrue(taxaListResult.Count == 3);
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 1));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 2));
                Assert.IsTrue(taxaListResult.Any(x => x.TaxonId == 4));


                // Test get taxon with invalid taxon ids
                filterController = new FilterController();
                strClipboard     = "47894789473849784937849;323343443344;-342342";
                result           = filterController.GetMatchingTaxa(strClipboard, RowDelimiter.Semicolon);
                jsonResult       = (JsonModel)result.Data;
                taxaListResult   = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 0);
                Assert.IsTrue(taxaListResult.Count == 0);
            }
        }
Example #4
0
        public void ListAllSharedOrganizationsForPrivateDomainTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""65fb7ec0-cac6-4f93-aa34-addc94dfc2c2"",
        ""url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2"",
        ""created_at"": ""2016-02-09T10:21:56Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""name-2038"",
        ""billing_enabled"": false,
        ""quota_definition_guid"": ""c7b6d6cc-0344-497e-978c-d40a9f1228fe"",
        ""status"": ""active"",
        ""quota_definition_url"": ""/v2/quota_definitions/c7b6d6cc-0344-497e-978c-d40a9f1228fe"",
        ""spaces_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/spaces"",
        ""domains_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/domains"",
        ""private_domains_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/private_domains"",
        ""users_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/users"",
        ""managers_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/managers"",
        ""billing_managers_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/billing_managers"",
        ""auditors_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/auditors"",
        ""app_events_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/app_events"",
        ""space_quota_definitions_url"": ""/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/space_quota_definitions""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();


                var obj = cfClient.PrivateDomains.ListAllSharedOrganizationsForPrivateDomain(guid).Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("65fb7ec0-cac6-4f93-aa34-addc94dfc2c2", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:56Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name-2038", TestUtil.ToTestableString(obj[0].Name), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj[0].BillingEnabled), true);
                Assert.AreEqual("c7b6d6cc-0344-497e-978c-d40a9f1228fe", TestUtil.ToTestableString(obj[0].QuotaDefinitionGuid), true);
                Assert.AreEqual("active", TestUtil.ToTestableString(obj[0].Status), true);
                Assert.AreEqual("/v2/quota_definitions/c7b6d6cc-0344-497e-978c-d40a9f1228fe", TestUtil.ToTestableString(obj[0].QuotaDefinitionUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/spaces", TestUtil.ToTestableString(obj[0].SpacesUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/domains", TestUtil.ToTestableString(obj[0].DomainsUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/private_domains", TestUtil.ToTestableString(obj[0].PrivateDomainsUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/users", TestUtil.ToTestableString(obj[0].UsersUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/managers", TestUtil.ToTestableString(obj[0].ManagersUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/billing_managers", TestUtil.ToTestableString(obj[0].BillingManagersUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/auditors", TestUtil.ToTestableString(obj[0].AuditorsUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/app_events", TestUtil.ToTestableString(obj[0].AppEventsUrl), true);
                Assert.AreEqual("/v2/organizations/65fb7ec0-cac6-4f93-aa34-addc94dfc2c2/space_quota_definitions", TestUtil.ToTestableString(obj[0].SpaceQuotaDefinitionsUrl), true);
            }
        }
Example #5
0
        public async Task TestCreate_CheckProperties()
        {
            using (ShimsContext.Create())
            {
                System.Data.Entity.Fakes.ShimDbContext.AllInstances.SetOf1 <Organization>((c) =>
                {
                    return(context.Organizations);
                });

                var organization = new Organization
                {
                    OrganizationId = 1
                };

                var socialMediaType = new SocialMediaType
                {
                    SocialMediaTypeId   = SocialMediaType.Facebook.Id,
                    SocialMediaTypeName = SocialMediaType.Facebook.Value
                };
                var userId              = 1;
                var user                = new User(userId);
                var value               = "value";
                var socialMediaTypeId   = socialMediaType.SocialMediaTypeId;
                var socialMediaPresense = new OrganizationSocialMediaPresence(user, socialMediaTypeId, value, organization.GetId());

                context.SetupActions.Add(() =>
                {
                    organization.SocialMedias.Clear();
                    context.SocialMediaTypes.Add(socialMediaType);
                    context.Organizations.Add(organization);
                });

                Action beforeServiceTester = () =>
                {
                    Assert.AreEqual(0, context.SocialMedias.Count());
                    Assert.AreEqual(0, context.Organizations.First().SocialMedias.Count);
                };

                Action <SocialMedia> tester = (serviceResult) =>
                {
                    Assert.IsNotNull(serviceResult);
                    Assert.AreEqual(1, organization.SocialMedias.Count);
                    var firstSocialMedia = context.Organizations.First().SocialMedias.First();
                    Assert.IsTrue(Object.ReferenceEquals(serviceResult, firstSocialMedia));

                    Assert.AreEqual(socialMediaType.SocialMediaTypeId, serviceResult.SocialMediaTypeId);
                    Assert.AreEqual(value, serviceResult.SocialMediaValue);
                    Assert.AreEqual(userId, serviceResult.History.CreatedBy);
                    Assert.AreEqual(userId, serviceResult.History.RevisedBy);
                    DateTimeOffset.Now.Should().BeCloseTo(serviceResult.History.CreatedOn, 2000);
                    DateTimeOffset.Now.Should().BeCloseTo(serviceResult.History.RevisedOn, 2000);
                };

                context.Revert();
                beforeServiceTester();
                var socialMedia = service.Create <Organization>(socialMediaPresense);
                tester(socialMedia);

                context.Revert();
                beforeServiceTester();
                socialMedia = await service.CreateAsync <Organization>(socialMediaPresense);

                tester(socialMedia);
            }
        }
        public void ListAllUserProvidedServiceInstancesTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""36988442-525f-4701-9733-862f3070686b"",
        ""url"": ""/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206"",
        ""created_at"": ""2016-09-02T11:52:23Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""name-2227"",
        ""credentials"": {
          ""creds-key-55"": ""creds-val-55""
        },
        ""space_guid"": ""36988442-525f-4701-9733-862f3070686b"",
        ""type"": ""user_provided_service_instance"",
        ""syslog_drain_url"": ""https://foo.com/url-94"",
        ""route_service_url"": null,
        ""space_url"": ""/v2/spaces/379a6da2-91dc-436f-94c5-69524644c0c9"",
        ""service_bindings_url"": ""/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206/service_bindings"",
        ""routes_url"": ""/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206/routes""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.UserProvidedServiceInstances.ListAllUserProvidedServiceInstances().Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("36988442-525f-4701-9733-862f3070686b", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:23Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name-2227", TestUtil.ToTestableString(obj[0].Name), true);
                Assert.AreEqual("36988442-525f-4701-9733-862f3070686b", TestUtil.ToTestableString(obj[0].SpaceGuid), true);
                Assert.AreEqual("user_provided_service_instance", TestUtil.ToTestableString(obj[0].Type), true);
                Assert.AreEqual("https://foo.com/url-94", TestUtil.ToTestableString(obj[0].SyslogDrainUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].RouteServiceUrl), true);
                Assert.AreEqual("/v2/spaces/379a6da2-91dc-436f-94c5-69524644c0c9", TestUtil.ToTestableString(obj[0].SpaceUrl), true);
                Assert.AreEqual("/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206/service_bindings", TestUtil.ToTestableString(obj[0].ServiceBindingsUrl), true);
                Assert.AreEqual("/v2/user_provided_service_instances/8d504d0d-8432-4fe7-9f97-e4425328f206/routes", TestUtil.ToTestableString(obj[0].RoutesUrl), true);
            }
        }
        public void GetVeteranProviderssTest()
        {
            using (ShimsContext.Create())
            {
                ShimVeteransRepo.AllInstances.GetServiceProvidersListOfInt32 =
                    (repo, ints) => this.serviceProviderList;

                var response = this.target.GetVeteranProviders(new List <int> {
                    1, 2
                });

                Assert.IsNotNull(response);
                Assert.AreEqual(4, response.Count);


                Assert.AreEqual(this.websiteAddress1, response[0].Address);
                Assert.AreEqual(this.serviceProviderList[0].ProviderServices.Count, response[0].Categories.Count);

                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.First().Contact.HelpLine,
                    response[0].CrisisNumber);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.First().Contact.Email,
                    response[0].Email);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.First().Contact.Phone,
                    response[0].PhoneNumber);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.First().Contact.Website,
                    response[0].Website);

                Assert.AreEqual(this.serviceProviderList[0].Description, response[0].Description);
                Assert.AreEqual(this.serviceProviderList[0].DisplayRank, response[0].DisplayRank);
                Assert.AreEqual(this.serviceProviderList[0].Description, response[0].Description);
                Assert.AreEqual(this.serviceProviderList[0].ProviderName, response[0].Name);

                Assert.AreEqual(this.websiteAddress2, response[1].Address);
                Assert.AreEqual(this.serviceProviderList[0].ProviderServices.Count, response[1].Categories.Count);

                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.Last().Contact.HelpLine,
                    response[1].CrisisNumber);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.Last().Contact.Email,
                    response[1].Email);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.Last().Contact.Phone,
                    response[1].PhoneNumber);
                Assert.AreEqual(
                    this.serviceProviderList[0].Locations.Last().Contact.Website,
                    response[1].Website);

                Assert.AreEqual(this.serviceProviderList[0].Description, response[1].Description);
                Assert.AreEqual(this.serviceProviderList[0].DisplayRank, response[1].DisplayRank);
                Assert.AreEqual(this.serviceProviderList[0].Description, response[1].Description);
                Assert.AreEqual(this.serviceProviderList[0].ProviderName, response[1].Name);

                Assert.AreEqual(this.websiteAddress1, response[2].Address);
                Assert.AreEqual(this.serviceProviderList[1].ProviderServices.Count, response[2].Categories.Count);

                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.First().Contact.HelpLine,
                    response[2].CrisisNumber);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.First().Contact.Email,
                    response[2].Email);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.First().Contact.Phone,
                    response[2].PhoneNumber);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.First().Contact.Website,
                    response[2].Website);

                Assert.AreEqual(this.serviceProviderList[1].Description, response[2].Description);
                Assert.AreEqual(this.serviceProviderList[1].DisplayRank, response[2].DisplayRank);
                Assert.AreEqual(this.serviceProviderList[1].Description, response[2].Description);
                Assert.AreEqual(this.serviceProviderList[1].ProviderName, response[2].Name);

                Assert.AreEqual(this.websiteAddress2, response[3].Address);
                Assert.AreEqual(this.serviceProviderList[1].ProviderServices.Count, response[3].Categories.Count);

                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.Last().Contact.HelpLine,
                    response[3].CrisisNumber);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.Last().Contact.Email,
                    response[3].Email);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.Last().Contact.Phone,
                    response[3].PhoneNumber);
                Assert.AreEqual(
                    this.serviceProviderList[1].Locations.Last().Contact.Website,
                    response[3].Website);

                Assert.AreEqual(this.serviceProviderList[1].Description, response[3].Description);
                Assert.AreEqual(this.serviceProviderList[1].DisplayRank, response[3].DisplayRank);
                Assert.AreEqual(this.serviceProviderList[1].Description, response[3].Description);
                Assert.AreEqual(this.serviceProviderList[1].ProviderName, response[3].Name);
            }
        }
        public void GetDataFromLists_WhenCalled_GetsData()
        {
            // Arrange
            const string query          = "query";
            const string expectedType   = "expectedType";
            const string expectedFormat = "expectedFormat";

            var actualCount = 0;

            GetMyWorkParams.FieldTypes    = new Dictionary <string, SPField>();
            GetMyWorkParams.SelectedLists = new List <string>()
            {
                DummyString
            };
            GetMyWorkParams.SelectedFields = new List <string>()
            {
                DummyString
            };
            var actual = default(XElement);
            var result = new XDocument();

            ShimsContext.ExecuteWithoutShims(() =>
            {
                result.Add(new XElement("MyWork"));
            });
            var dTable = new DataTable();

            dTable.Columns.Add(ListIdColumn);
            dTable.Columns.Add(ItemIdColumn);
            var row = dTable.NewRow();

            row[ListIdColumn] = guid.ToString().ToUpper();
            row[ItemIdColumn] = 1.ToString(CultureInfo.InvariantCulture);
            dTable.Rows.Add(row);

            ShimMyWork.GetArchivedWebsGuid = _ => new List <Guid>()
            {
                Guid.NewGuid()
            };
            ShimMyWork.GetWorkingOnSPWeb = _ => dTable;
            ShimMyWork.GetTypeAndFormatIDictionaryOfStringSPFieldStringStringOutStringOut = (IDictionary <string, SPField> fieldTypesParam, string selectedField, out string type, out string format) =>
            {
                type   = expectedType;
                format = expectedFormat;
            };
            ShimXContainer.AllInstances.AddObject = (instance, element) =>
            {
                if (instance.NodeType == XmlNodeType.Element)
                {
                    if (((XElement)instance).Name.LocalName.Equals("MyWork"))
                    {
                        actual      = (XElement)element;
                        actualCount = actualCount + 1;
                        return;
                    }
                }
                ShimsContext.ExecuteWithoutShims(() =>
                {
                    instance.Add(element);
                });
            };

            // Act
            privateObj.Invoke(
                GetDataFromListsMethodName,
                BindingFlags.Static | BindingFlags.NonPublic,
                new object[] { result, query, spSite.Instance, spWeb.Instance });

            // Assert
            actual.ShouldSatisfyAllConditions(
                () => actualCount.ShouldBe(1),
                () => actual.Name.ShouldBe("Item"),
                () => actual.Attribute("ID").Value.ShouldBe(DummyString),
                () => actual.Attribute("ListID").Value.ShouldBe(guid.ToString().ToUpper()),
                () => actual.Attribute("WorkingOn").Value.ToLower().ShouldBe("true"));
        }
 public void SetUp()
 {
     _shims    = ShimsContext.Create();
     _customer = new CustomerMain();
     CreateMaster();
 }
        public void AssignToFieldServiceTeamTestMethod()
        {
            using (ShimsContext.Create())
            {
                AssignToFieldServiceTeam assignToFieldServiceTeam = new StubAssignToFieldServiceTeam();

                var serviceProvider     = new StubIServiceProvider();
                var pluginContext       = new StubIPluginExecutionContext();
                var organizationService = new StubIOrganizationService();

                pluginContext.PrimaryEntityNameGet = () => "msdyn_workorder";
                pluginContext.PrimaryEntityIdGet   = () => new Guid("54D94FC2-52AD-E511-8158-1458D04DB4D1");
                ParameterCollection paramCollection = new ParameterCollection();
                Entity workOrder = new Entity("msdyn_workorder");
                workOrder.Attributes["msdyn_servicerequest"] = new EntityReference("incident", new Guid("884A078B-0467-E711-80F5-3863BB3C0660"));
                paramCollection.Add("Target", workOrder);

                pluginContext.InputParametersGet = () => paramCollection;

                Entity incidentImage = new Entity("msdyn_workorder");
                incidentImage.Attributes["msdyn_servicerequest"] = new EntityReference("incident", new Guid("884A078B-0467-E711-80F5-3863BB3C0660"));
                var postImage = new EntityImageCollection {
                    (new KeyValuePair <string, Entity>("PostImage", incidentImage))
                };
                PluginVariables(serviceProvider, pluginContext, organizationService, 40, "Create", postImage);

                organizationService.RetrieveMultipleQueryBase = (query) =>
                {
                    EntityCollection collection = new EntityCollection();
                    string           entityName = string.Empty;
                    if (query.GetType().Name.Equals("FetchExpression"))
                    {
                        if (((FetchExpression)query).Query.Contains("<entity name='ava_keyvaluepair'>"))
                        {
                            entityName = "ava_keyvaluepair";
                        }
                    }
                    else if (query.GetType().Name.Equals("QueryExpression"))
                    {
                        entityName = ((QueryExpression)query).EntityName;
                    }
                    else
                    {
                        entityName = ((QueryByAttribute)query).EntityName;
                    }

                    if (entityName == "smp_providermatrix")
                    {
                        Entity annotation = new Entity("smp_providermatrix");
                        annotation.Id = new Guid("884A078B-0466-E711-80F5-3863BB3C0560");
                        annotation.Attributes["smp_buildingid"] = new EntityReference("smp_building", new Guid("884A078B-0467-E711-80F5-3863BB3C1560"))
                        {
                            Name = "building"
                        };
                        annotation.Attributes["smp_problemclassid"] = new EntityReference("smp_problemclass", new Guid("884A078B-0468-E711-80F5-3863BB3C0560"))
                        {
                            Name = "problemClass"
                        };
                        annotation.Attributes["smp_problemtypeid"] = new EntityReference("smp_problemtype", new Guid("884A078B-0469-E711-80F5-3863BB3C0560"))
                        {
                            Name = "problemType"
                        };
                        annotation.Attributes["smp_fieldserviceteam"] = new EntityReference("team", new Guid("884A078B-0469-E711-80E5-3863BB3C0560"))
                        {
                            Name = "Team1"
                        };
                        annotation.Attributes["statecode"]  = new OptionSetValue(0);
                        annotation.Attributes["statuscode"] = new OptionSetValue(1);
                        collection.Entities.Add(annotation);
                    }

                    return(collection);
                };

                organizationService.RetrieveStringGuidColumnSet = delegate(string entity, Guid guid, ColumnSet secondaryUserColumnSet)
                {
                    if (entity == "incident")
                    {
                        Entity incident = new Entity("incident");
                        incident.Id = new Guid("884A078B-0467-E711-80F5-3863BB3C0660");
                        incident.Attributes["smp_problembuilding"] = new EntityReference("smp_building", new Guid("884A078B-0467-E711-80F5-3863BB3C1560"))
                        {
                            Name = "building"
                        };
                        incident.Attributes["new_problemroomnumber"] = new EntityReference("smp_room", new Guid("884A078B-0467-E711-80F5-3863BB3C0560"))
                        {
                            Name = "room"
                        };
                        incident.Attributes["caseorigincode"] = new OptionSetValue(915240000);
                        incident.Attributes["smp_duedate"]    = new DateTime(2018, 1, 8);
                        incident.Attributes["smp_duedatebybuildingtimezone"]           = "2018-01-08";
                        incident.Attributes["smp_occureddatetimebybuildingtimezone"]   = "2018-01-08";
                        incident.Attributes["smp_submitteddatetimebybuildingtimezone"] = "2018-01-08";
                        incident.Attributes["smp_createddatetimebybuildingtimezone"]   = "2018-01-08";
                        incident.Attributes["smp_priorityid"] = new EntityReference("smp_priority", new Guid("884A078B-0466-E711-80F5-3863BB3C0560"))
                        {
                            Name = "priority"
                        };
                        incident.Attributes["smp_problemclassid"] = new EntityReference("smp_problemclass", new Guid("884A078B-0468-E711-80F5-3863BB3C0560"))
                        {
                            Name = "problemClass"
                        };
                        incident.Attributes["smp_problemtypeid"] = new EntityReference("smp_problemtype", new Guid("884A078B-0469-E711-80F5-3863BB3C0560"))
                        {
                            Name = "problemType"
                        };
                        return(incident);
                    }

                    return(null);
                };

                assignToFieldServiceTeam.Execute(serviceProvider);
            }
        }
        public void ListAllServiceAuthTokensDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 3,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""443e0580-8b1e-47d2-b618-6a934ebc622d"",
        ""url"": ""/v2/service_auth_tokens/443e0580-8b1e-47d2-b618-6a934ebc622d"",
        ""created_at"": ""2015-04-16T12:04:17+00:00"",
        ""updated_at"": null
      },
      ""entity"": {
        ""label"": ""label-11"",
        ""provider"": ""provider-11""
      }
    },
    {
      ""metadata"": {
        ""guid"": ""476626c0-a007-4590-abae-38ebe4898f64"",
        ""url"": ""/v2/service_auth_tokens/476626c0-a007-4590-abae-38ebe4898f64"",
        ""created_at"": ""2015-04-16T12:04:17+00:00"",
        ""updated_at"": null
      },
      ""entity"": {
        ""label"": ""label-12"",
        ""provider"": ""provider-12""
      }
    },
    {
      ""metadata"": {
        ""guid"": ""f4569a3d-76e2-4cbe-a849-acf1bae623e4"",
        ""url"": ""/v2/service_auth_tokens/f4569a3d-76e2-4cbe-a849-acf1bae623e4"",
        ""created_at"": ""2015-04-16T12:04:17+00:00"",
        ""updated_at"": null
      },
      ""entity"": {
        ""label"": ""label-13"",
        ""provider"": ""provider-13""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.ServiceAuthTokensDeprecated.ListAllServiceAuthTokensDeprecated().Result;

                Assert.AreEqual("3", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("443e0580-8b1e-47d2-b618-6a934ebc622d", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_auth_tokens/443e0580-8b1e-47d2-b618-6a934ebc622d", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:17+00:00", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("label-11", TestUtil.ToTestableString(obj[0].Label), true);
                Assert.AreEqual("provider-11", TestUtil.ToTestableString(obj[0].Provider), true);
                Assert.AreEqual("476626c0-a007-4590-abae-38ebe4898f64", TestUtil.ToTestableString(obj[1].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_auth_tokens/476626c0-a007-4590-abae-38ebe4898f64", TestUtil.ToTestableString(obj[1].EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:17+00:00", TestUtil.ToTestableString(obj[1].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[1].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("label-12", TestUtil.ToTestableString(obj[1].Label), true);
                Assert.AreEqual("provider-12", TestUtil.ToTestableString(obj[1].Provider), true);
                Assert.AreEqual("f4569a3d-76e2-4cbe-a849-acf1bae623e4", TestUtil.ToTestableString(obj[2].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_auth_tokens/f4569a3d-76e2-4cbe-a849-acf1bae623e4", TestUtil.ToTestableString(obj[2].EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:17+00:00", TestUtil.ToTestableString(obj[2].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[2].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("label-13", TestUtil.ToTestableString(obj[2].Label), true);
                Assert.AreEqual("provider-13", TestUtil.ToTestableString(obj[2].Provider), true);
            }
        }
 public void TearDown()
 {
     ShimsContext.Reset();
     _shimsContext.Dispose();
     _fakeHttpContext.Dispose();
 }
Example #13
0
 public void TestInitialize()
 {
     _shimContext        = ShimsContext.Create();
     ShimDateTime.NowGet = () => DummyDateTimeNow;
 }
Example #14
0
 public void TestInitialize()
 {
     _shimObject = ShimsContext.Create();
     CreateMasterPage();
     CreateTestObjects();
 }
Example #15
0
        public void UpdateServiceDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""7c4a071d-3b2b-431d-93ca-a8decef2aac1"",
    ""url"": ""/v2/services/7c4a071d-3b2b-431d-93ca-a8decef2aac1"",
    ""created_at"": ""2016-02-09T10:21:54Z"",
    ""updated_at"": ""2016-02-09T10:21:54Z""
  },
  ""entity"": {
    ""label"": ""SomeMysqlService"",
    ""provider"": ""MySql Provider"",
    ""url"": ""http://myql.provider.com"",
    ""description"": ""Mysql stores things for you"",
    ""long_description"": null,
    ""version"": ""2.0"",
    ""info_url"": null,
    ""active"": true,
    ""bindable"": true,
    ""unique_id"": ""3eed8156-8432-4a1c-a4ca-afc5e15f589f"",
    ""extra"": null,
    ""tags"": [

    ],
    ""requires"": [

    ],
    ""documentation_url"": null,
    ""service_broker_guid"": ""e7a84f57-cd1f-4938-87b6-c385000927ee"",
    ""plan_updateable"": false,
    ""service_plans_url"": ""/v2/services/7c4a071d-3b2b-431d-93ca-a8decef2aac1/service_plans""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                UpdateServiceDeprecatedRequest value = new UpdateServiceDeprecatedRequest();


                var obj = cfClient.Services.UpdateServiceDeprecated(value).Result;


                Assert.AreEqual("7c4a071d-3b2b-431d-93ca-a8decef2aac1", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/7c4a071d-3b2b-431d-93ca-a8decef2aac1", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:54Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-02-09T10:21:54Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("SomeMysqlService", TestUtil.ToTestableString(obj.Label), true);
                Assert.AreEqual("MySql Provider", TestUtil.ToTestableString(obj.Provider), true);
                Assert.AreEqual("http://myql.provider.com", TestUtil.ToTestableString(obj.Url), true);
                Assert.AreEqual("Mysql stores things for you", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.LongDescription), true);
                Assert.AreEqual("2.0", TestUtil.ToTestableString(obj.Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.InfoUrl), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Bindable), true);
                Assert.AreEqual("3eed8156-8432-4a1c-a4ca-afc5e15f589f", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.DocumentationUrl), true);
                Assert.AreEqual("e7a84f57-cd1f-4938-87b6-c385000927ee", TestUtil.ToTestableString(obj.ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.PlanUpdateable), true);
                Assert.AreEqual("/v2/services/7c4a071d-3b2b-431d-93ca-a8decef2aac1/service_plans", TestUtil.ToTestableString(obj.ServicePlansUrl), true);
            }
        }
        public void GetVirtualPath_OverriddenCultureByRouteDictionaryThatDoesNotExist_ReturnsNeutralLocalizationRoute()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");

                LocalizationCollectionRoute localizationCollectionRoute =
                    new LocalizationCollectionRoute(new HttpRoute("Home",
                                                                  new HttpRouteValueDictionary()
                {
                    { "controller", "Home" }, { "action", "Index" }
                }, new HttpRouteValueDictionary(),
                                                                  new HttpRouteValueDictionary(), null));

                PrivateObject privateObject = new PrivateObject(localizationCollectionRoute);

                IDictionary <string, LocalizationRoute> routes =
                    (IDictionary <string, LocalizationRoute>)privateObject.GetProperty("LocalizedRoutesContainer");

                ShimLocalizationRoute localizationRouteNeutral =
                    new ShimLocalizationRoute(new LocalizationRoute("Welcome",
                                                                    new HttpRouteValueDictionary()
                {
                    { "controller", "Home" }, { "action", "Index" }
                }, new HttpRouteValueDictionary(),
                                                                    new HttpRouteValueDictionary(), null, string.Empty));

                (new ShimHttpRoute(localizationRouteNeutral)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
                    (requestContext, values) => new HttpVirtualPathData(localizationRouteNeutral.Instance, "Welcome");

                routes[string.Empty] = localizationRouteNeutral;

                ShimLocalizationRoute localizationRouteEnglish =
                    new ShimLocalizationRoute(new LocalizationRoute("Welcome",
                                                                    new HttpRouteValueDictionary()
                {
                    { "controller", "Home" }, { "action", "Index" }
                }, new HttpRouteValueDictionary(),
                                                                    new HttpRouteValueDictionary(), null, "en"));

                (new ShimHttpRoute(localizationRouteEnglish)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
                    (requestContext, values) => new HttpVirtualPathData(localizationRouteEnglish.Instance, "Welcome");

                routes["en"] = localizationRouteEnglish;

                ShimLocalizationRoute localizationRouteGerman =
                    new ShimLocalizationRoute(new LocalizationRoute("Willkommen",
                                                                    new HttpRouteValueDictionary()
                {
                    { "controller", "Home" }, { "action", "Index" }
                }, new HttpRouteValueDictionary(),
                                                                    new HttpRouteValueDictionary(), null, "de"));

                routes["de"] = localizationRouteGerman;

                (new ShimHttpRoute(localizationRouteGerman)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
                    (requestContext, values) => new HttpVirtualPathData(localizationRouteGerman.Instance, "Willkommen");

                // Act
                IHttpVirtualPathData virtualPathData = localizationCollectionRoute.GetVirtualPath(null,
                                                                                                  new HttpRouteValueDictionary()
                {
                    { "Culture", "es" }
                });

                // Assert
                Assert.AreEqual(virtualPathData.Route, localizationRouteNeutral.Instance);
            }
        }
        public void ListAllRoutesForUserProvidedServiceInstanceTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""617e7edb-9781-4218-9afd-0af010cf3c1d"",
        ""url"": ""/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a"",
        ""created_at"": ""2016-09-02T11:52:24Z"",
        ""updated_at"": ""2016-09-02T11:52:24Z""
      },
      ""entity"": {
        ""host"": ""host-30"",
        ""path"": """",
        ""domain_guid"": ""617e7edb-9781-4218-9afd-0af010cf3c1d"",
        ""space_guid"": ""617e7edb-9781-4218-9afd-0af010cf3c1d"",
        ""service_instance_guid"": ""617e7edb-9781-4218-9afd-0af010cf3c1d"",
        ""port"": null,
        ""domain_url"": ""/v2/private_domains/8d584cbd-74c3-45e1-8088-0e2731802d3a"",
        ""space_url"": ""/v2/spaces/bcbb461b-556e-4008-b9c8-53855d1b1f2e"",
        ""service_instance_url"": ""/v2/user_provided_service_instances/17d4f286-b394-48b7-a4f0-18582eedccb3"",
        ""apps_url"": ""/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a/apps"",
        ""route_mappings_url"": ""/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a/route_mappings""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();


                var obj = cfClient.UserProvidedServiceInstances.ListAllRoutesForUserProvidedServiceInstance(guid).Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("617e7edb-9781-4218-9afd-0af010cf3c1d", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:24Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-09-02T11:52:24Z", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("host-30", TestUtil.ToTestableString(obj[0].Host), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Path), true);
                Assert.AreEqual("617e7edb-9781-4218-9afd-0af010cf3c1d", TestUtil.ToTestableString(obj[0].DomainGuid), true);
                Assert.AreEqual("617e7edb-9781-4218-9afd-0af010cf3c1d", TestUtil.ToTestableString(obj[0].SpaceGuid), true);
                Assert.AreEqual("617e7edb-9781-4218-9afd-0af010cf3c1d", TestUtil.ToTestableString(obj[0].ServiceInstanceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Port), true);
                Assert.AreEqual("/v2/private_domains/8d584cbd-74c3-45e1-8088-0e2731802d3a", TestUtil.ToTestableString(obj[0].DomainUrl), true);
                Assert.AreEqual("/v2/spaces/bcbb461b-556e-4008-b9c8-53855d1b1f2e", TestUtil.ToTestableString(obj[0].SpaceUrl), true);
                Assert.AreEqual("/v2/user_provided_service_instances/17d4f286-b394-48b7-a4f0-18582eedccb3", TestUtil.ToTestableString(obj[0].ServiceInstanceUrl), true);
                Assert.AreEqual("/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a/apps", TestUtil.ToTestableString(obj[0].AppsUrl), true);
                Assert.AreEqual("/v2/routes/d5575577-ad7f-4fa6-bacc-ec0f7db6835a/route_mappings", TestUtil.ToTestableString(obj[0].RouteMappingsUrl), true);
            }
        }
 public void TestInitialize()
 {
     _shimObject = ShimsContext.Create();
 }
        public void ListAllServiceBindingsForUserProvidedServiceInstanceTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""2b2156e8-4ed2-469a-bed6-98b39f6e3c51"",
        ""url"": ""/v2/service_bindings/2f3720ab-2e5b-4278-973a-c2eba5b0fb19"",
        ""created_at"": ""2016-09-02T11:52:24Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""app_guid"": ""2b2156e8-4ed2-469a-bed6-98b39f6e3c51"",
        ""service_instance_guid"": ""2b2156e8-4ed2-469a-bed6-98b39f6e3c51"",
        ""credentials"": {
          ""creds-key-60"": ""creds-val-60""
        },
        ""binding_options"": {

        },
        ""gateway_data"": null,
        ""gateway_name"": """",
        ""syslog_drain_url"": null,
        ""volume_mounts"": [

        ],
        ""app_url"": ""/v2/apps/6a9dd637-10b6-4ddd-bc4a-477ea65b78d7"",
        ""service_instance_url"": ""/v2/user_provided_service_instances/a53bf95a-7777-4f4e-9abd-31fea4dc3c9c""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();


                var obj = cfClient.UserProvidedServiceInstances.ListAllServiceBindingsForUserProvidedServiceInstance(guid).Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("2b2156e8-4ed2-469a-bed6-98b39f6e3c51", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_bindings/2f3720ab-2e5b-4278-973a-c2eba5b0fb19", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:24Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("2b2156e8-4ed2-469a-bed6-98b39f6e3c51", TestUtil.ToTestableString(obj[0].AppGuid), true);
                Assert.AreEqual("2b2156e8-4ed2-469a-bed6-98b39f6e3c51", TestUtil.ToTestableString(obj[0].ServiceInstanceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].GatewayData), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].GatewayName), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].SyslogDrainUrl), true);
                Assert.AreEqual("/v2/apps/6a9dd637-10b6-4ddd-bc4a-477ea65b78d7", TestUtil.ToTestableString(obj[0].AppUrl), true);
                Assert.AreEqual("/v2/user_provided_service_instances/a53bf95a-7777-4f4e-9abd-31fea4dc3c9c", TestUtil.ToTestableString(obj[0].ServiceInstanceUrl), true);
            }
        }
Example #20
0
        public void Impl_CreateWriteReadFile()
        {
            var          backingFile  = new MemoryStream();
            const string filename     = "file.ext";
            var          fileMetadata = new MetaData
            {
                Bytes  = 0,
                Is_Dir = false,
                Path   = "/" + filename
            };

            using (ShimsContext.Create())
            {
                Dokan.Fakes.ShimDokanNet.DokanResetTimeoutUInt32DokanFileInfo            = (u, info) => true;
                DropNet.Fakes.ShimDropNetClient.AllInstances.GetMetaDataString           = (client, s) => fileMetadata;
                DropNet.Fakes.ShimDropNetClient.AllInstances.StartChunkedUploadByteArray = (client, bytes) =>
                {
                    backingFile.Seek(0, SeekOrigin.Begin);
                    backingFile.Write(bytes, 0, bytes.Length);
                    return(new ChunkedUpload {
                        UploadId = "1", Offset = bytes.Length
                    });
                };
                DropNet.Fakes.ShimDropNetClient.AllInstances.AppendChunkedUploadChunkedUploadByteArray = (client, upload, bytes) =>
                {
                    backingFile.Seek(upload.Offset + 1, SeekOrigin.Begin);
                    backingFile.Write(bytes, 0, bytes.Length);
                    upload.Offset += bytes.Length;
                    return(upload);
                };
                DropNet.Fakes.ShimDropNetClient.AllInstances.CommitChunkedUploadChunkedUploadStringBoolean = (client, upload, path, overwrite) =>
                {
                    fileMetadata.Bytes = backingFile.Length;
                    return(fileMetadata);
                };
                DropNet.Fakes.ShimDropNetClient.AllInstances.UploadFileStringStringByteArray = (client, s, arg3, arg4) => fileMetadata;
                DropNet.Fakes.ShimDropNetClient.AllInstances.GetFileStringInt64Int64String   = (client, path, startByte, endByte, rev) =>
                {
                    var buf = new byte[endByte - startByte];
                    backingFile.Seek(startByte, SeekOrigin.Begin);
                    backingFile.Read(buf, 0, (int)(endByte - startByte));
                    return(buf);
                };

                var  name         = _clientPrefix + "\\" + filename;
                uint writtenBytes = 0;
                // write
                var code = _impl.CreateFile(name, FileAccess.ReadWrite, FileShare.None, FileMode.OpenOrCreate, FileOptions.DeleteOnClose, _info);
                Assert.AreEqual(0, code);
                code = _impl.WriteFile(name, _buffer, ref writtenBytes, 0, _info);
                Assert.AreEqual(0, code);
                Assert.AreEqual(20, (int)writtenBytes);
                // close file
                code = _impl.CloseFile(name, _info);
                Assert.AreEqual(0, code);
                // read
                uint readBytes = 0;
                var  buffer    = new byte[20];
                code = _impl.ReadFile(name, buffer, ref readBytes, 0, _info);
                Assert.AreEqual(0, code);
                Assert.AreEqual(20, (int)readBytes);
                Assert.AreEqual(_buffer.Length, buffer.Length);
                for (var i = 0; i < readBytes; i++)
                {
                    Assert.AreEqual(_buffer[i], buffer[i]);
                }
            }
        }
Example #21
0
        public void ListAllPrivateDomainsTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 4,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""0092b149-ca9d-4e2c-9f36-eab07b08a6d5"",
        ""url"": ""/v2/private_domains/0092b149-ca9d-4e2c-9f36-eab07b08a6d5"",
        ""created_at"": ""2016-02-09T10:21:53Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""vcap.me"",
        ""owning_organization_guid"": ""21b05e41-2a93-45aa-8b06-b5512532a29a"",
        ""owning_organization_url"": ""/v2/organizations/21b05e41-2a93-45aa-8b06-b5512532a29a"",
        ""shared_organizations_url"": ""/v2/private_domains/0092b149-ca9d-4e2c-9f36-eab07b08a6d5/shared_organizations""
      }
    },
    {
      ""metadata"": {
        ""guid"": ""59f7b1b4-3f46-4045-85c9-3a1cbb701d98"",
        ""url"": ""/v2/private_domains/59f7b1b4-3f46-4045-85c9-3a1cbb701d98"",
        ""created_at"": ""2016-02-09T10:21:56Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""domain-53.example.com"",
        ""owning_organization_guid"": ""0e665765-c6dd-4cfb-8a6e-180d518340b3"",
        ""owning_organization_url"": ""/v2/organizations/0e665765-c6dd-4cfb-8a6e-180d518340b3"",
        ""shared_organizations_url"": ""/v2/private_domains/59f7b1b4-3f46-4045-85c9-3a1cbb701d98/shared_organizations""
      }
    },
    {
      ""metadata"": {
        ""guid"": ""5f4f9856-8fdb-4c27-8555-5e6848d16bea"",
        ""url"": ""/v2/private_domains/5f4f9856-8fdb-4c27-8555-5e6848d16bea"",
        ""created_at"": ""2016-02-09T10:21:56Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""domain-54.example.com"",
        ""owning_organization_guid"": ""3289d627-3544-4a16-a2a1-215cecae6e4d"",
        ""owning_organization_url"": ""/v2/organizations/3289d627-3544-4a16-a2a1-215cecae6e4d"",
        ""shared_organizations_url"": ""/v2/private_domains/5f4f9856-8fdb-4c27-8555-5e6848d16bea/shared_organizations""
      }
    },
    {
      ""metadata"": {
        ""guid"": ""06c624bb-c5c3-4e60-94c4-7d852b03e6b3"",
        ""url"": ""/v2/private_domains/06c624bb-c5c3-4e60-94c4-7d852b03e6b3"",
        ""created_at"": ""2016-02-09T10:21:56Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""domain-55.example.com"",
        ""owning_organization_guid"": ""82269e63-2062-4191-894a-749ac041919d"",
        ""owning_organization_url"": ""/v2/organizations/82269e63-2062-4191-894a-749ac041919d"",
        ""shared_organizations_url"": ""/v2/private_domains/06c624bb-c5c3-4e60-94c4-7d852b03e6b3/shared_organizations""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.PrivateDomains.ListAllPrivateDomains().Result;

                Assert.AreEqual("4", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("0092b149-ca9d-4e2c-9f36-eab07b08a6d5", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/private_domains/0092b149-ca9d-4e2c-9f36-eab07b08a6d5", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:53Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("vcap.me", TestUtil.ToTestableString(obj[0].Name), true);
                Assert.AreEqual("21b05e41-2a93-45aa-8b06-b5512532a29a", TestUtil.ToTestableString(obj[0].OwningOrganizationGuid), true);
                Assert.AreEqual("/v2/organizations/21b05e41-2a93-45aa-8b06-b5512532a29a", TestUtil.ToTestableString(obj[0].OwningOrganizationUrl), true);
                Assert.AreEqual("/v2/private_domains/0092b149-ca9d-4e2c-9f36-eab07b08a6d5/shared_organizations", TestUtil.ToTestableString(obj[0].SharedOrganizationsUrl), true);
                Assert.AreEqual("59f7b1b4-3f46-4045-85c9-3a1cbb701d98", TestUtil.ToTestableString(obj[1].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/private_domains/59f7b1b4-3f46-4045-85c9-3a1cbb701d98", TestUtil.ToTestableString(obj[1].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:56Z", TestUtil.ToTestableString(obj[1].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[1].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("domain-53.example.com", TestUtil.ToTestableString(obj[1].Name), true);
                Assert.AreEqual("0e665765-c6dd-4cfb-8a6e-180d518340b3", TestUtil.ToTestableString(obj[1].OwningOrganizationGuid), true);
                Assert.AreEqual("/v2/organizations/0e665765-c6dd-4cfb-8a6e-180d518340b3", TestUtil.ToTestableString(obj[1].OwningOrganizationUrl), true);
                Assert.AreEqual("/v2/private_domains/59f7b1b4-3f46-4045-85c9-3a1cbb701d98/shared_organizations", TestUtil.ToTestableString(obj[1].SharedOrganizationsUrl), true);
                Assert.AreEqual("5f4f9856-8fdb-4c27-8555-5e6848d16bea", TestUtil.ToTestableString(obj[2].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/private_domains/5f4f9856-8fdb-4c27-8555-5e6848d16bea", TestUtil.ToTestableString(obj[2].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:56Z", TestUtil.ToTestableString(obj[2].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[2].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("domain-54.example.com", TestUtil.ToTestableString(obj[2].Name), true);
                Assert.AreEqual("3289d627-3544-4a16-a2a1-215cecae6e4d", TestUtil.ToTestableString(obj[2].OwningOrganizationGuid), true);
                Assert.AreEqual("/v2/organizations/3289d627-3544-4a16-a2a1-215cecae6e4d", TestUtil.ToTestableString(obj[2].OwningOrganizationUrl), true);
                Assert.AreEqual("/v2/private_domains/5f4f9856-8fdb-4c27-8555-5e6848d16bea/shared_organizations", TestUtil.ToTestableString(obj[2].SharedOrganizationsUrl), true);
                Assert.AreEqual("06c624bb-c5c3-4e60-94c4-7d852b03e6b3", TestUtil.ToTestableString(obj[3].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/private_domains/06c624bb-c5c3-4e60-94c4-7d852b03e6b3", TestUtil.ToTestableString(obj[3].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:56Z", TestUtil.ToTestableString(obj[3].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[3].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("domain-55.example.com", TestUtil.ToTestableString(obj[3].Name), true);
                Assert.AreEqual("82269e63-2062-4191-894a-749ac041919d", TestUtil.ToTestableString(obj[3].OwningOrganizationGuid), true);
                Assert.AreEqual("/v2/organizations/82269e63-2062-4191-894a-749ac041919d", TestUtil.ToTestableString(obj[3].OwningOrganizationUrl), true);
                Assert.AreEqual("/v2/private_domains/06c624bb-c5c3-4e60-94c4-7d852b03e6b3/shared_organizations", TestUtil.ToTestableString(obj[3].SharedOrganizationsUrl), true);
            }
        }
Example #22
0
        public void ListAllServicesTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""57c1be4b-8158-462b-b881-8946f8125817"",
        ""url"": ""/v2/services/57c1be4b-8158-462b-b881-8946f8125817"",
        ""created_at"": ""2016-02-09T10:21:54Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""label"": ""label-60"",
        ""provider"": null,
        ""url"": null,
        ""description"": ""desc-180"",
        ""long_description"": null,
        ""version"": null,
        ""info_url"": null,
        ""active"": true,
        ""bindable"": true,
        ""unique_id"": ""60871676-cbb0-4657-b6f2-f8963d596c2d"",
        ""extra"": null,
        ""tags"": [

        ],
        ""requires"": [

        ],
        ""documentation_url"": null,
        ""service_broker_guid"": ""f55f29eb-5021-416c-9273-757db37507c6"",
        ""plan_updateable"": false,
        ""service_plans_url"": ""/v2/services/57c1be4b-8158-462b-b881-8946f8125817/service_plans""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.Services.ListAllServices().Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("57c1be4b-8158-462b-b881-8946f8125817", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/57c1be4b-8158-462b-b881-8946f8125817", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:54Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("label-60", TestUtil.ToTestableString(obj[0].Label), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Provider), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Url), true);
                Assert.AreEqual("desc-180", TestUtil.ToTestableString(obj[0].Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].LongDescription), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].InfoUrl), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj[0].Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj[0].Bindable), true);
                Assert.AreEqual("60871676-cbb0-4657-b6f2-f8963d596c2d", TestUtil.ToTestableString(obj[0].UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].DocumentationUrl), true);
                Assert.AreEqual("f55f29eb-5021-416c-9273-757db37507c6", TestUtil.ToTestableString(obj[0].ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj[0].PlanUpdateable), true);
                Assert.AreEqual("/v2/services/57c1be4b-8158-462b-b881-8946f8125817/service_plans", TestUtil.ToTestableString(obj[0].ServicePlansUrl), true);
            }
        }
Example #23
0
        public void ListServiceUsageEventsTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 2,
  ""total_pages"": 2,
  ""prev_url"": null,
  ""next_url"": ""/v2/service_usage_events?after_guid=eba75f82-bdee-4ee8-8a34-2e7ed274fd64=asc=2=1"",
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""url"": ""/v2/service_usage_events/13e0e494-ae3d-4232-bf7f-01697b4ac2ef"",
        ""created_at"": ""2016-09-02T11:52:06Z""
      },
      ""entity"": {
        ""state"": ""CREATED"",
        ""org_guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""space_guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""space_name"": ""name-590"",
        ""service_instance_guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""service_instance_name"": ""name-591"",
        ""service_instance_type"": ""type-8"",
        ""service_plan_guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""service_plan_name"": ""name-592"",
        ""service_guid"": ""efa93bc2-0ac9-41c0-8d55-8aaa397a3e21"",
        ""service_label"": ""label-21""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.ServiceUsageEvents.ListServiceUsageEvents().Result;

                Assert.AreEqual("2", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("2", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("/v2/service_usage_events?after_guid=eba75f82-bdee-4ee8-8a34-2e7ed274fd64=asc=2=1", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_usage_events/13e0e494-ae3d-4232-bf7f-01697b4ac2ef", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:06Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("CREATED", TestUtil.ToTestableString(obj[0].State), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].OrgGuid), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].SpaceGuid), true);
                Assert.AreEqual("name-590", TestUtil.ToTestableString(obj[0].SpaceName), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].ServiceInstanceGuid), true);
                Assert.AreEqual("name-591", TestUtil.ToTestableString(obj[0].ServiceInstanceName), true);
                Assert.AreEqual("type-8", TestUtil.ToTestableString(obj[0].ServiceInstanceType), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].ServicePlanGuid), true);
                Assert.AreEqual("name-592", TestUtil.ToTestableString(obj[0].ServicePlanName), true);
                Assert.AreEqual("efa93bc2-0ac9-41c0-8d55-8aaa397a3e21", TestUtil.ToTestableString(obj[0].ServiceGuid), true);
                Assert.AreEqual("label-21", TestUtil.ToTestableString(obj[0].ServiceLabel), true);
            }
        }
Example #24
0
        public void ListAllServicePlansForServiceTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""3ee77690-d694-485a-ba1a-beaebacbde07"",
        ""url"": ""/v2/service_plans/3ee77690-d694-485a-ba1a-beaebacbde07"",
        ""created_at"": ""2016-02-09T10:21:54Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""name-1918"",
        ""free"": false,
        ""description"": ""desc-178"",
        ""service_guid"": ""e9cb91f8-d70d-4361-a631-922d37fb1d79"",
        ""extra"": null,
        ""unique_id"": ""6cf5bab4-9b9b-4b63-b4ec-edb2c44700ee"",
        ""public"": true,
        ""active"": true,
        ""service_url"": ""/v2/services/e9cb91f8-d70d-4361-a631-922d37fb1d79"",
        ""service_instances_url"": ""/v2/service_plans/3ee77690-d694-485a-ba1a-beaebacbde07/service_instances""
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();


                var obj = cfClient.Services.ListAllServicePlansForService(guid).Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("3ee77690-d694-485a-ba1a-beaebacbde07", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/service_plans/3ee77690-d694-485a-ba1a-beaebacbde07", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:54Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name-1918", TestUtil.ToTestableString(obj[0].Name), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj[0].Free), true);
                Assert.AreEqual("desc-178", TestUtil.ToTestableString(obj[0].Description), true);
                Assert.AreEqual("e9cb91f8-d70d-4361-a631-922d37fb1d79", TestUtil.ToTestableString(obj[0].ServiceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].Extra), true);
                Assert.AreEqual("6cf5bab4-9b9b-4b63-b4ec-edb2c44700ee", TestUtil.ToTestableString(obj[0].UniqueId), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj[0].Public), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj[0].Active), true);
                Assert.AreEqual("/v2/services/e9cb91f8-d70d-4361-a631-922d37fb1d79", TestUtil.ToTestableString(obj[0].ServiceUrl), true);
                Assert.AreEqual("/v2/service_plans/3ee77690-d694-485a-ba1a-beaebacbde07/service_instances", TestUtil.ToTestableString(obj[0].ServiceInstancesUrl), true);
            }
        }
Example #25
0
        public void ListAllOrganizationQuotaDefinitionsTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""total_results"": 1,
  ""total_pages"": 1,
  ""prev_url"": null,
  ""next_url"": null,
  ""resources"": [
    {
      ""metadata"": {
        ""guid"": ""e9c996f0-1c65-474c-adcc-e0f6ccaf957c"",
        ""url"": ""/v2/quota_definitions/fc8583ac-04e8-4aa0-b832-445e8ca74889"",
        ""created_at"": ""2016-09-02T11:52:15Z"",
        ""updated_at"": null
      },
      ""entity"": {
        ""name"": ""default"",
        ""non_basic_services_allowed"": true,
        ""total_services"": 100,
        ""total_routes"": 1000,
        ""total_private_domains"": -1,
        ""memory_limit"": 10240,
        ""trial_db_allowed"": false,
        ""instance_memory_limit"": -1,
        ""app_instance_limit"": -1,
        ""app_task_limit"": -1,
        ""total_service_keys"": -1,
        ""total_reserved_route_ports"": 0
      }
    }
  ]
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();


                var obj = cfClient.OrganizationQuotaDefinitions.ListAllOrganizationQuotaDefinitions().Result;

                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalResults), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Properties.TotalPages), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.PreviousUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Properties.NextUrl), true);
                Assert.AreEqual("e9c996f0-1c65-474c-adcc-e0f6ccaf957c", TestUtil.ToTestableString(obj[0].EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/quota_definitions/fc8583ac-04e8-4aa0-b832-445e8ca74889", TestUtil.ToTestableString(obj[0].EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:15Z", TestUtil.ToTestableString(obj[0].EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj[0].EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("default", TestUtil.ToTestableString(obj[0].Name), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj[0].NonBasicServicesAllowed), true);
                Assert.AreEqual("100", TestUtil.ToTestableString(obj[0].TotalServices), true);
                Assert.AreEqual("1000", TestUtil.ToTestableString(obj[0].TotalRoutes), true);
                Assert.AreEqual("-1", TestUtil.ToTestableString(obj[0].TotalPrivateDomains), true);
                Assert.AreEqual("10240", TestUtil.ToTestableString(obj[0].MemoryLimit), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj[0].TrialDbAllowed), true);
                Assert.AreEqual("-1", TestUtil.ToTestableString(obj[0].InstanceMemoryLimit), true);
                Assert.AreEqual("-1", TestUtil.ToTestableString(obj[0].AppInstanceLimit), true);
                Assert.AreEqual("-1", TestUtil.ToTestableString(obj[0].AppTaskLimit), true);
                Assert.AreEqual("-1", TestUtil.ToTestableString(obj[0].TotalServiceKeys), true);
                Assert.AreEqual("0", TestUtil.ToTestableString(obj[0].TotalReservedRoutePorts), true);
            }
        }
Example #26
0
        public void RetrieveServiceTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""6a64a40b-3a64-4bee-b74e-69c9f10ed755"",
    ""url"": ""/v2/services/6a64a40b-3a64-4bee-b74e-69c9f10ed755"",
    ""created_at"": ""2016-02-09T10:21:54Z"",
    ""updated_at"": null
  },
  ""entity"": {
    ""label"": ""label-59"",
    ""provider"": null,
    ""url"": null,
    ""description"": ""desc-179"",
    ""long_description"": null,
    ""version"": null,
    ""info_url"": null,
    ""active"": true,
    ""bindable"": true,
    ""unique_id"": ""24b4dc28-ae0c-43dd-8d70-b233638eed97"",
    ""extra"": null,
    ""tags"": [

    ],
    ""requires"": [

    ],
    ""documentation_url"": null,
    ""service_broker_guid"": ""0a7ceba7-4e96-4287-9410-79f5cba5a747"",
    ""plan_updateable"": false,
    ""service_plans_url"": ""/v2/services/6a64a40b-3a64-4bee-b74e-69c9f10ed755/service_plans""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();


                var obj = cfClient.Services.RetrieveService(guid).Result;


                Assert.AreEqual("6a64a40b-3a64-4bee-b74e-69c9f10ed755", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/6a64a40b-3a64-4bee-b74e-69c9f10ed755", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:54Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("label-59", TestUtil.ToTestableString(obj.Label), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Provider), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Url), true);
                Assert.AreEqual("desc-179", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.LongDescription), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.InfoUrl), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Bindable), true);
                Assert.AreEqual("24b4dc28-ae0c-43dd-8d70-b233638eed97", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.DocumentationUrl), true);
                Assert.AreEqual("0a7ceba7-4e96-4287-9410-79f5cba5a747", TestUtil.ToTestableString(obj.ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.PlanUpdateable), true);
                Assert.AreEqual("/v2/services/6a64a40b-3a64-4bee-b74e-69c9f10ed755/service_plans", TestUtil.ToTestableString(obj.ServicePlansUrl), true);
            }
        }
        public void AddAndRemoveFilteredTaxaTest()
        {
            using (ShimsContext.Create())
            {
                int[]                 taxaIds;
                string                strJson;
                FilterController      filterController;
                RedirectResult        result;
                JsonNetResult         result2;
                JsonModel             jsonResult;
                List <TaxonViewModel> taxaListResult;

                filterController = new FilterController();
                taxaIds          = new int[] { 1, 2, 5 };
                strJson          = JsonConvert.SerializeObject(taxaIds);

                ActionResult viewResult = filterController.TaxonFromIds();
                Assert.IsNotNull(viewResult);

                // Test add taxa to MySettings
                result = filterController.AddTaxaToFilter(strJson, "Home/Index");
                Assert.IsTrue(result.Url == "Home/Index");
                Assert.IsTrue(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(1));
                Assert.IsTrue(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(2));
                Assert.IsTrue(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(5));
                Assert.IsFalse(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(3));

                // Test remove taxon from MySettings
                result = filterController.RemoveFilteredTaxon("Home/Index", 2);
                Assert.IsTrue(result.Url == "Home/Index");
                Assert.IsTrue(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(1));
                Assert.IsTrue(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(5));
                Assert.IsFalse(SessionHandler.MySettings.Filter.Taxa.TaxonIds.Contains(2));


                // Test Get filtered taxa
                result2        = filterController.GetFilteredTaxa();
                jsonResult     = (JsonModel)result2.Data;
                taxaListResult = (List <TaxonViewModel>)jsonResult.Data;
                Assert.IsTrue(jsonResult.Success);
                Assert.IsTrue(jsonResult.Total == 2);
                Assert.IsTrue(taxaListResult.Count == 2);
                int[] taxonIdsInList = new int[] { taxaListResult[0].TaxonId, taxaListResult[1].TaxonId };
                Assert.IsTrue(taxonIdsInList.Contains(1));
                Assert.IsTrue(taxonIdsInList.Contains(5));
                Assert.IsFalse(taxonIdsInList.Contains(2));

                // Remove all filtered taxa
                Assert.AreEqual(2, SessionHandler.MySettings.Filter.Taxa.TaxonIds.Count);
                result = filterController.RemoveAllFilteredTaxon("Home/Index");
                Assert.AreEqual("Home/Index", result.Url);
                Assert.AreEqual(0, SessionHandler.MySettings.Filter.Taxa.TaxonIds.Count);


                // Test Get filtered taxa with unexpected error
                MakeGetCurrentUserFunctionCallThrowException();
                result2    = filterController.GetFilteredTaxa();
                jsonResult = (JsonModel)result2.Data;
                Assert.IsFalse(jsonResult.Success);
                Assert.IsNull(jsonResult.Data);
            }
        }
Example #28
0
        public void CreateServiceDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""b876f258-f75d-4e6e-b0bc-5554e233b669"",
    ""url"": ""/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669"",
    ""created_at"": ""2016-02-09T10:21:55Z"",
    ""updated_at"": null
  },
  ""entity"": {
    ""label"": ""SomeMysqlService"",
    ""provider"": ""MySql Provider"",
    ""url"": ""http://myql.provider.com"",
    ""description"": ""Mysql stores things for you"",
    ""long_description"": null,
    ""version"": ""2.0"",
    ""info_url"": null,
    ""active"": false,
    ""bindable"": true,
    ""unique_id"": null,
    ""extra"": null,
    ""tags"": [

    ],
    ""requires"": [

    ],
    ""documentation_url"": null,
    ""service_broker_guid"": null,
    ""plan_updateable"": false,
    ""service_plans_url"": ""/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669/service_plans""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                CreateServiceDeprecatedRequest value = new CreateServiceDeprecatedRequest();


                var obj = cfClient.Services.CreateServiceDeprecated(value).Result;


                Assert.AreEqual("b876f258-f75d-4e6e-b0bc-5554e233b669", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:55Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("SomeMysqlService", TestUtil.ToTestableString(obj.Label), true);
                Assert.AreEqual("MySql Provider", TestUtil.ToTestableString(obj.Provider), true);
                Assert.AreEqual("http://myql.provider.com", TestUtil.ToTestableString(obj.Url), true);
                Assert.AreEqual("Mysql stores things for you", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.LongDescription), true);
                Assert.AreEqual("2.0", TestUtil.ToTestableString(obj.Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.InfoUrl), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Bindable), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.DocumentationUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.PlanUpdateable), true);
                Assert.AreEqual("/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669/service_plans", TestUtil.ToTestableString(obj.ServicePlansUrl), true);
            }
        }
        public void AddAndRemoveFilteredFieldTest()
        {
            using (ShimsContext.Create())
            {
                // Assign
                string           strClass;
                string           strFieldValue;
                string           strFieldId;
                string           strFieldName;
                string           strCompareOperator;
                string           strLogicalOperator;
                FilterController filterController;
                RedirectResult   result;
                FieldViewModel   model;
                ISpeciesObservationFieldDescription fieldDescription;

                ISpeciesObservationFieldSearchCriteria expectedField =
                    new SpeciesObservationFieldSearchCriteria()
                {
                    Class = new SpeciesObservationClass()
                    {
                        Id = SpeciesObservationClassId.DarwinCore
                    },
                    Operator = CompareOperator.Like,
                    Property = new SpeciesObservationProperty()
                    {
                        Id = SpeciesObservationPropertyId.Owner
                    },
                    Type  = DataType.String,
                    Value = "flodin"
                };

                filterController   = new FilterController();
                strClass           = "DarwinCore";
                strFieldValue      = "flodin";
                strFieldId         = "146";
                strFieldName       = "Owner";
                strCompareOperator = "LIKE";
                strLogicalOperator = "OR";

                model = new FieldViewModel();
                model.FieldDescriptionTypes = new FieldViewModel.SpeciesObservationFieldDescriptionType();
                model.FieldDescriptionTypes.FieldDescriptionTypes = new Dictionary <string, List <ISpeciesObservationFieldDescription> >();
                fieldDescription      = new SpeciesObservationFieldDescription();
                fieldDescription.Type = DataType.String;
                model.FieldDescriptionTypes.FieldDescriptionTypes.Add(strClass, new List <ISpeciesObservationFieldDescription> {
                    fieldDescription
                });

                // Act
                ActionResult viewResult = filterController.Field();

                // Test add field to MySettings
                result = filterController.AddFieldToFilter(
                    strClass,
                    strFieldValue,
                    strFieldId,
                    strFieldName,
                    strCompareOperator,
                    strLogicalOperator,
                    "Home/Index");

                // Assert
                Assert.IsNotNull(viewResult);
                Assert.IsTrue(result.Url == "Home/Index");
                Assert.AreEqual(expectedField.Type, fieldDescription.Type);
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldFilterExpressions.Count == 1);
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldFilterExpressions[0].Class.Id.Equals(expectedField.Class.Id));
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldFilterExpressions[0].Value.Equals(expectedField.Value));
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldLogicalOperator == LogicalOperator.Or);

                // Test remove field from MySettings
                result = filterController.ResetFields("Home/Index");
                Assert.IsTrue(result.Url == "Home/Index");
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldFilterExpressions.Count == 0);
                Assert.IsTrue(SessionHandler.MySettings.Filter.Field.FieldLogicalOperator == LogicalOperator.And);
            }
        }
        public async Task GetValidAccessToken_ExpiredAccessToken_Success()
        {
            using (ShimsContext.Create())
            {
                string testToken = "LsaQWEWAFAFS21882=";

                Credentials testCredentials = new Credentials
                {
                    UserEmail    = "*****@*****.**",
                    UserNickName = "test",
                    AccessToken  = testToken,
                    RefreshToken = "KSDndfnWJLAJSMNK"
                };

                Credentials updatedCredentials = new Credentials
                {
                    UserEmail    = "*****@*****.**",
                    UserNickName = "test_updated",
                    AccessToken  = "LsaQWEWAFAFS21882=UPDATED",
                    RefreshToken = "KSDndfnWJLAJSMNK___UPDATED"
                };

                // set up the mock for ICredentialStorageService object
                var cssMock = new Mock <ICredentialStorageService>();
                cssMock.SetupGet(service => service.Credentials).Returns(testCredentials);
                cssMock.Setup(service => service.CheckIfCredentialsFileExists()).Returns(true);
                cssMock.SetupSet(service => service.Credentials = updatedCredentials).Verifiable();

                // set up the CredentialsChanged so we can fake its invocation
                EventHandler <Credentials> credentialsChangedEventHandler = null;

                // capture the event handler
                ShimAuth0ServiceProxy.AllInstances.CredentialsChangedAddEventHandlerOfCredentials = (proxy, handler) =>
                {
                    credentialsChangedEventHandler = handler;
                };

                // invoke the event handler and return updatedCredentials
                ShimAuth0ServiceProxy.AllInstances.RefreshAccessToken = proxy =>
                {
                    credentialsChangedEventHandler.Invoke(proxy, updatedCredentials);
                    return(Task.FromResult(updatedCredentials));
                };

                // set up the current date and valid date of the token for comparison to fail
                ShimJwtSecurityToken.ConstructorString       = (token, s) => { };
                ShimJwtSecurityToken.AllInstances.ValidToGet = token => new DateTime(1995, 9, 4);
                ShimDateTime.UtcNowGet = () => new DateTime(1995, 10, 2);

                /*---ACT---*/

                PlatformsIdentityPlugin plugin = new PlatformsIdentityPlugin(cssMock.Object);
                string refreshedToken          = await plugin.GetValidAccessToken();

                /*---ASSERT---*/

                Assert.AreEqual(refreshedToken, updatedCredentials.AccessToken);
                cssMock.Verify(service => service.Save(), Times.AtLeastOnce);
                cssMock.VerifyAll();
            }
        }