コード例 #1
0
        /// <summary>
        /// Get the list of children Items for the Parent.
        /// </summary>
        /// <param name="parentID"></param>
        private static void GetListItems(string parentID)
        {
            //GET the RepositoryInfo
            var configuration = GetClientConfig();
            var instance      = new RepositoryApi(configuration);
            var response      = instance.ApiV1RepositoryInfoGet();
            //GET the Sets
            var  instanceSets = new SetApi(configuration);
            Guid guid         = new Guid(parentID);
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);

            //GET the list of GUID
            GetLatestItemsRequest request = new GetLatestItemsRequest
            {
                Identifiers = new List <IdentifierInRequest>()
            };

            foreach (IdentifierTriple itemTriple in responseSets)
            {
                request.Identifiers.Add(new IdentifierInRequest(itemTriple.Item3, itemTriple.Item1, itemTriple.Item2));
            }
            var instanceList = new ItemApi(configuration);
            var responseList = instanceList.ApiV1ItemGetListLatestPost(request);

            foreach (RepositoryItem item in responseList)
            {
                if (item != null)
                {
                    Console.WriteLine(item.ToJson());
                }
            }
        }
コード例 #2
0
        public void GetListItemsByAgencyByParentIDByItemTypeTest(string agency, string parentID, string itemType)
        {
            //Converting string parameter to GUID
            Guid itemTypeGuid  = new Guid(itemType);
            var  configuration = GetClientConfig();

            //GET the Sets
            var  instanceSets = new Colectica.RestClientV1.Api.SetApi(configuration);
            Guid guid         = new Guid(parentID);
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);

            //GET the list of GUID
            GetLatestItemsRequest request = new GetLatestItemsRequest
            {
                Identifiers = new List <IdentifierInRequest>()
            };

            foreach (IdentifierTriple itemTriple in responseSets)
            {
                request.Identifiers.Add(new IdentifierInRequest(itemTriple.Item3, itemTriple.Item1, itemTriple.Item2));
            }
            var instanceList = new ItemApi(configuration);
            var responseList = instanceList.ApiV1ItemGetListLatestPost(request);

            /// <see cref="QueryApi.ApiV1QueryRelationshipByobjectDescriptionsPost(GraphSearchRequest)"/>
            //var mapItemsChild = new Dictionary<RepositoryItem, List<RepositoryItem>>();
            foreach (RepositoryItem item in responseList)
            {
                if (item != null && item.ItemType == itemTypeGuid && item.AgencyId == agency)
                {
                    Console.WriteLine(item.ToJson());
                }
            }
        }
コード例 #3
0
        public async Task <IActionResult> Index(string item)
        {
            var itemApi = new ItemApi();

            var items = await itemApi.Get(item);

            return(View(items));
        }
コード例 #4
0
 public async Task EndFixtureTests()
 {
     if (TestContext.Parameters.Count == 0)
     {
         PlaceApi.DeletePlaces();
         AppApi.DeleteApps();
         ItemApi.DeleteItems();
     }
     await _mm.InboxHousekeepingAsync(_mm.ClientCxM).ContinueWith(task => _mm.Dispose());
 }
コード例 #5
0
        public void ApiV1ItemByAgencyByIdGetTest()
        {
            var configuration = GetClientConfig();
            //GET the Sets
            var  instanceSets = new Colectica.RestClientV1.Api.SetApi(configuration);
            Guid guid         = new Guid("52c5dd34-1b5f-460b-8904-6f0f2897f6a1");
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);
            var  instanceList = new ItemApi(configuration);
            var  response     = instanceList.ApiV1ItemByAgencyByIdGet("int.example", guid);

            Assert.NotNull(response.AgencyId);
        }
コード例 #6
0
        public void ApiV1ItemByAgencyByIdByVersionDescriptionGetWithHttpInfoTest()
        {
            var configuration = GetClientConfig();
            //GET the Sets
            var  instanceSets = new Colectica.RestClientV1.Api.SetApi(configuration);
            Guid guid         = new Guid("52c5dd34-1b5f-460b-8904-6f0f2897f6a1");
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);
            var  instanceList = new ItemApi(configuration);
            var  response     = instanceList.ApiV1ItemByAgencyByIdByVersionDescriptionGetWithHttpInfo("int.example", guid, 1L);

            Assert.Equal(200, response.StatusCode);
        }
コード例 #7
0
 public void EndFixtureTests()
 {
     if (IsEachFixtureInNewBrowser)
     {
         ClosePrimaryBrowser();
     }
     if (TestContext.Parameters.Count == 0)
     {
         PlaceApi.DeletePlaces();
         AppApi.DeleteApps();
         ItemApi.DeleteItems();
     }
 }
コード例 #8
0
ファイル: Steps.cs プロジェクト: Nojj02/shoppingcart
        public static async Task ThenUserCanComputeTotalCostOfShoppingItems(
            List <dynamic> shoppingItems,
            decimal expectedTotalCost,
            string couponCode = "")
        {
            var itemApi        = new ItemApi(ApiUrl);
            var computeCostDto =
                new
            {
                CouponCode    = couponCode,
                ShoppingItems =
                    shoppingItems
                    .Select(async x =>
                {
                    var item = await itemApi.GetByCodeAsync(x.ItemCode);

                    return(new
                    {
                        Id = item.Id,
                        Quantity = x.Quantity
                    });
                }).Select(x => x.Result)
                    .ToList()
            };

            var httpContent        = new StringContent(JsonConvert.SerializeObject(computeCostDto), Encoding.UTF8, "application/json");
            var postRequestMessage =
                new HttpRequestMessage(
                    method: HttpMethod.Post,
                    requestUri: new Uri("http://localhost:9050/calculator/computeCost"))
            {
                Content = httpContent
            };

            using (var httpClient = new HttpClient())
            {
                var postResponse = await httpClient.SendAsync(postRequestMessage);

                Assert.Equal(HttpStatusCode.OK, postResponse.StatusCode);

                var body =
                    JsonConvert.DeserializeAnonymousType(await postResponse.Content.ReadAsStringAsync(),
                                                         new
                {
                    TotalCost = 0.0m
                });

                Assert.Equal(expectedTotalCost, body.TotalCost);
            }
        }
コード例 #9
0
 public void EndFixtureTests()
 {
     IsUseAllPageReadyChecks = true; // use normal set of page readiness checks
     if (IsEachFixtureInNewBrowser)
     {
         ClosePrimaryBrowser();
     }
     if (TestContext.Parameters.Count == 0)
     {
         PlaceApi.DeletePlaces();
         AppApi.DeleteApps();
         ItemApi.DeleteItems();
     }
 }
コード例 #10
0
        public async Task <IActionResult> Save(ItemViewModel itemViewModel)
        {
            var itemApi = new ItemApi();

            try
            {
                await itemApi.Add(itemViewModel);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("New", new { id = itemViewModel.Id, name = itemViewModel.Name, price = itemViewModel.Price, errorMessage = ex.Message }));
            }

            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public void ApiV1ItemGetDescriptionsPostTest()
        {
            var configuration = GetClientConfig();
            //GET the Sets
            var  instanceSets = new Colectica.RestClientV1.Api.SetApi(configuration);
            Guid guid         = new Guid("52c5dd34-1b5f-460b-8904-6f0f2897f6a1");
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);
            var  instanceList = new ItemApi(configuration);
            GetRepositoryItemDescriptionsRequest request     = new GetRepositoryItemDescriptionsRequest();
            List <IdentifierInRequest>           identifiers = new List <IdentifierInRequest>();
            IdentifierInRequest item = new IdentifierInRequest("int.example", guid, 1L);

            identifiers.Add(item);
            request.Identifiers = identifiers;
            List <RepositoryItemMetadata> response = instanceList.ApiV1ItemGetDescriptionsPost(request);

            Assert.True(response.Count > 0);
        }
コード例 #12
0
        /// <summary>
        /// Get the list of children Items for the parentID for a specific agency
        /// and a specific type with a limit of objects returned.
        /// </summary>
        /// <param name="agency"></param>
        /// <param name="parentID"></param>
        /// <param name="itemType"></param>
        /// <param name="limitMax"></param>
        private static void GetListItems(string agency, string parentID, string itemType, long limitMax)
        {
            //Converting string parameter to GUID
            Guid itemTypeGuid = new Guid(itemType);

            //GET the RepositoryInfo
            var configuration = GetClientConfig();
            var instance      = new RepositoryApi(configuration);
            var response      = instance.ApiV1RepositoryInfoGet();

            //GET the Sets
            var  instanceSets = new SetApi(configuration);
            Guid guid         = new Guid(parentID);
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);

            //GET the list of GUID
            GetLatestItemsRequest request = new GetLatestItemsRequest
            {
                Identifiers = new List <IdentifierInRequest>()
            };

            foreach (IdentifierTriple itemTriple in responseSets)
            {
                request.Identifiers.Add(new IdentifierInRequest(itemTriple.Item3, itemTriple.Item1, itemTriple.Item2));
            }
            var  instanceList = new ItemApi(configuration);
            var  responseList = instanceList.ApiV1ItemGetListLatestPost(request);
            long countdown    = 0L;

            foreach (RepositoryItem item in responseList)
            {
                if (countdown <= limitMax)
                {
                    if (item != null && item.ItemType == itemTypeGuid && item.AgencyId == agency)
                    {
                        Console.WriteLine(item.ToJson());
                    }
                }
                countdown++;
            }
        }
コード例 #13
0
        public void GetListItemsByParentIDFileTest(string parentID)
        {
            if (!(Directory.Exists("c:/temp")))
            {
                Directory.CreateDirectory("c:/temp");
            }
            StreamWriter fw = new StreamWriter("C:/temp/test.json");

            var configuration = GetClientConfig();
            //GET the Sets
            var  instanceSets = new Colectica.RestClientV1.Api.SetApi(configuration);
            Guid guid         = new Guid(parentID);
            var  responseSets = instanceSets.ApiV1SetByAgencyByIdByVersionGet("int.example", guid, 1);

            //GET the list of GUID
            GetLatestItemsRequest request = new GetLatestItemsRequest
            {
                Identifiers = new List <IdentifierInRequest>()
            };

            foreach (IdentifierTriple itemTriple in responseSets)
            {
                request.Identifiers.Add(new IdentifierInRequest(itemTriple.Item3, itemTriple.Item1, itemTriple.Item2));
            }
            var instanceList = new ItemApi(configuration);
            var responseList = instanceList.ApiV1ItemGetListLatestPost(request);

            foreach (RepositoryItem item in responseList)
            {
                if (item != null)
                {
                    fw.WriteLine(item.ToJson());
                }
            }
            fw.Close();
            Assert.True(File.Exists("C:/temp/test.json"));
            File.Delete("C:/temp/test.json");
            Assert.False(File.Exists("C:/temp/test.json"));
        }
コード例 #14
0
        public void setActiveHost()
        {
            mobileAppStorage = CdbMobileAppStorage.Instance;
            var config = mobileAppStorage.getActiveConfiguration();
            var auth   = mobileAppStorage.getActiveAuth();
            var host   = config.CdbAddress;

            itemApiInstance          = new ItemApi(host);
            machineApiInstance       = new MachineDesignItemsApi(host);
            locationApiInstance      = new LocationItemsApi(host);
            authApiInstance          = new AuthenticationApi(host);
            propertyValueApiInstance = new PropertyValueApi(host);
            usersApiInstace          = new UsersApi(host);
            testApiInstance          = new TestApi(host);
            propertyTypeApiInstance  = new PropertyTypeApi(host);

            if (auth != null)
            {
                var token = auth.AuthToken;
                applyAuthToken(token);
            }
        }
コード例 #15
0
 public static void UpdateItemsCall()
 {
     const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
     var          api       = new ItemApi(simpleKey);
 }
コード例 #16
0
ファイル: BnsModule.cs プロジェクト: ShajeshJ/ShajeshBot
        public async Task GetMarketplaceValue([Remainder] string item)
        {
            //Search for the item through personal sheets to find corresponding id
            var itemSearchApi = new ItemSearchApi(_ssService);
            var id            = await itemSearchApi.GetItemId(item);

            if (id == 0)
            {
                await ReplyAsync($"Could not find item with search key '{item}'");

                return;
            }

            //Use item id to retrieve item details (in particular, image for the item)
            var itemApi     = new ItemApi();
            var itemDetails = await itemApi.GetItemDetails(id);

            if (itemDetails == null)
            {
                await ReplyAsync($"Could not find item with search key '{item}'");

                return;
            }

            //Use item id to retrieve current marketplace value of the item
            var mpApi    = new MarketplaceApi();
            var listings = await mpApi.GetMarketplaceListing(id);

            var embed = new EmbedBuilder();

            embed.ThumbnailUrl = itemDetails.ImgUrl;
            embed.Title        = itemDetails.Name;

            var maxListing = Math.Min(10, listings?.Listings.Length ?? 0);

            var formattedListings = "";

            for (int i = 0; i < maxListing; i++)
            {
                var listing = listings.Listings[i];

                formattedListings += $"{listing.PricePerItem.GoldPart} {GoldIcon} {listing.PricePerItem.SilverPart} {SilverIcon} x {listing.Count}";
                formattedListings += $"   |   {listing.Price.Total/10000.0} g Total\r\n";
            }

            formattedListings = string.IsNullOrEmpty(formattedListings) ? "<No listings available>" : formattedListings;

            embed.AddField(new EmbedFieldBuilder()
            {
                Name  = $"Lowest marketplace listings for {itemDetails.Name}.",
                Value = formattedListings
            });

            embed.Footer = new EmbedFooterBuilder()
            {
                Text = "Data retrieved from the Unofficial BnS API. Documentation: https://slate.silveress.ie/docs_bns"
            };

            if (listings != null)
            {
                embed.Timestamp = new DateTimeOffset(listings.DateRetrieved);
            }

            await ReplyAsync("", embed : embed.Build());
        }
コード例 #17
0
ファイル: BnsModule.cs プロジェクト: ShajeshJ/ShajeshBot
        public async Task GetCraftingCost(int amount, [Remainder] string item)
        {
            //Search for the item through personal sheets to find corresponding id
            var itemSearchApi = new ItemSearchApi(_ssService);
            var id            = await itemSearchApi.GetItemId(item);

            if (id == 0)
            {
                await ReplyAsync($"Could not find item with search key '{item}'");

                return;
            }

            //Use item id to retrieve item details (in particular, image for the item)
            var itemApi     = new ItemApi();
            var itemDetails = await itemApi.GetItemDetails(id);

            if (itemDetails == null)
            {
                await ReplyAsync($"Could not find item with search key '{item}'");

                return;
            }

            //Use item id to retrieve current marketplace value of the item
            var crApi        = new CraftingApi();
            var craftRecipes = await crApi.GetCraftingCost(itemDetails.Name);

            var chosenRecipe = craftRecipes.Where(r => r.Quantity == amount).FirstOrDefault();

            if (chosenRecipe == null)
            {
                if (craftRecipes.Length == 0)
                {
                    await ReplyAsync($"No crafting recipes available for '{itemDetails.Name}'");
                }
                else
                {
                    var amountList = craftRecipes.Aggregate("", (accum, cur) => accum + cur.Quantity + ", ", accum => accum.TrimEnd(',', ' '));
                    await ReplyAsync($"Must choose one of the following craft amounts for '{itemDetails.Name}': {amountList}");
                }
                return;
            }

            var altRecipes = craftRecipes.Where(r => r.Quantity != chosenRecipe.Quantity);

            var mpApi = new MarketplaceApi();
            var tasks = new List <Task>();

            var mainItemListing = await mpApi.GetMarketplaceListing(itemDetails.Id);

            if ((mainItemListing?.Listings.Length ?? 0) == 0)
            {
                await ReplyAsync($"No maketplace listings available for '{itemDetails.Name}'");

                return;
            }

            var outputPrice = mainItemListing.Listings.First().PricePerItem *chosenRecipe.Quantity;

            if (chosenRecipe.Ingredients != null)
            {
                //Currently the drive only supports searching for items in a serial manner
                //Can avoid this slow linear search if/when the unofficial api returns ids along with item names
                for (int i = 0; i < chosenRecipe.Ingredients.Length; i++)
                {
                    var idx = i;
                    chosenRecipe.Ingredients[idx].Id = await itemSearchApi.GetItemId(chosenRecipe.Ingredients[idx].Name);

                    tasks.Add(Task.Run(async() =>
                    {
                        chosenRecipe.Ingredients[idx].Cost = new Gold(0);

                        //Some items may not be sellable items, or may not be listed on the marketplace; we ignore these
                        if (chosenRecipe.Ingredients[idx].Id != 0)
                        {
                            var listing = await mpApi.GetMarketplaceListing(chosenRecipe.Ingredients[idx].Id);

                            if ((listing?.Listings.Length ?? 0) != 0)
                            {
                                chosenRecipe.Ingredients[idx].Cost = listing.Listings.First().PricePerItem *chosenRecipe.Ingredients[idx].Quantity;
                            }
                        }
                    }));
                }
            }

            if (chosenRecipe.AttemptIngredients != null)
            {
                //Currently the drive only supports searching for items in a serial manner
                //Can avoid this slow linear search if/when the unofficial api returns ids along with item names
                for (int i = 0; i < chosenRecipe.AttemptIngredients.Length; i++)
                {
                    var idx = i;
                    chosenRecipe.AttemptIngredients[idx].Id = await itemSearchApi.GetItemId(chosenRecipe.AttemptIngredients[idx].Name);

                    tasks.Add(Task.Run(async() =>
                    {
                        chosenRecipe.AttemptIngredients[idx].Cost = new Gold(0);

                        //Some items may not be sellable items, or may not be listed on the marketplace; we ignore these
                        if (chosenRecipe.AttemptIngredients[idx].Id != 0)
                        {
                            var listing = await mpApi.GetMarketplaceListing(chosenRecipe.AttemptIngredients[idx].Id);

                            if ((listing?.Listings.Length ?? 0) != 0)
                            {
                                chosenRecipe.AttemptIngredients[idx].Cost = listing.Listings.First().PricePerItem
                                                                            *chosenRecipe.AttemptIngredients[idx].Quantity;
                            }
                        }
                    }));
                }
            }

            await Task.WhenAll(tasks);

            var craftCost = chosenRecipe.Cost;

            var individualCostStr = $"{chosenRecipe.Cost.GoldPart} {GoldIcon} {chosenRecipe.Cost.SilverPart} {SilverIcon} - Crafting Price\r\n";

            if (chosenRecipe.Ingredients != null)
            {
                foreach (var ing in chosenRecipe.Ingredients)
                {
                    craftCost += ing.Cost;

                    if (ing.Cost == 0)
                    {
                        individualCostStr += $"No marketplace value available - {ing.Name} x {ing.Quantity}\r\n";
                    }
                    else
                    {
                        individualCostStr += $"{ing.Cost.GoldPart} {GoldIcon} {ing.Cost.SilverPart} {SilverIcon} - {ing.Name} x {ing.Quantity}\r\n";
                    }
                }
            }

            if (chosenRecipe.AttemptIngredients != null)
            {
                foreach (var atmpt in chosenRecipe.AttemptIngredients)
                {
                    craftCost += atmpt.Cost;

                    if (atmpt.Cost == 0)
                    {
                        individualCostStr += $"No marketplace value available - {atmpt.Name} x {atmpt.Quantity}\r\n";
                    }
                    else
                    {
                        individualCostStr += $"{atmpt.Cost.GoldPart} {GoldIcon} {atmpt.Cost.SilverPart} {SilverIcon} - {atmpt.Name} x {atmpt.Quantity}\r\n";
                    }
                }
            }

            var netCost = outputPrice - craftCost;

            var embed = new EmbedBuilder();

            embed.ThumbnailUrl = itemDetails.ImgUrl;
            embed.Title        = itemDetails.Name;

            if (chosenRecipe.SuccessRate > 0.0 && chosenRecipe.SuccessRate < 1.0)
            {
                embed.Title += " (chance to fail)";
            }

            embed.Description = $"Net Earnings: {netCost.GoldPart} {GoldIcon} {netCost.SilverPart} {SilverIcon}";

            var altCraftAmtStr = altRecipes.Aggregate("", (accum, cur) => accum + cur.Quantity + ", ", accum => accum.TrimEnd(',', ' '));

            var craftSpecsStr = $"Source: {chosenRecipe.CraftingSource}";

            craftSpecsStr += chosenRecipe.CraftDuration > 0 ? $"\r\nDuration: {chosenRecipe.CraftDuration} hrs" : "";
            craftSpecsStr += string.IsNullOrEmpty(altCraftAmtStr) ? ""
                                : $"\r\nAmount: {chosenRecipe.Quantity} (alternate craft amounts: {altCraftAmtStr})";

            embed.AddField("Crafting Information", craftSpecsStr, false);

            embed.AddField("Market Price", $"{outputPrice.GoldPart} {GoldIcon} {outputPrice.SilverPart} {SilverIcon}", true);
            embed.AddField("Crafting Cost", $"{craftCost.GoldPart} {GoldIcon} {craftCost.SilverPart} {SilverIcon}", true);

            embed.AddField("Individual Item Costs", individualCostStr, false);

            embed.Footer = new EmbedFooterBuilder()
            {
                Text = "Data retrieved from the Unofficial BnS API. Documentation: https://slate.silveress.ie/docs_bns"
            };

            await ReplyAsync("", embed : embed.Build());
        }
コード例 #18
0
        // daily report emails send at 8:00 AM (Europe/Kiev),
        // this test needs some time to prepare environment, so run it before 7:59 AM
        public void RT07310_FollowItemsEmailReport()
        {
            if (DateTime.Now.TimeOfDay > new TimeSpan(07, 59, 00))
            {
                Assert.Inconclusive("Canceled run. The test should be started before 07:59 AM");
            }
            CurrentTenant = TenantTitle.reportitems;
            var userProperties = UserDirectoryApi.GetUserData(TestConfig.NewUser);

            if (userProperties == null)
            {
                AccountApi.CreateNewAccount(TestConfig.NewUser);
                UserDirectoryApi.SetUserStatus(TestConfig.NewUser, UserStatus.Active);
                UserDirectoryApi.AssignRolesToUser(TestConfig.NewUser,
                                                   new [] { UserRole.CxmAdmin });
                userProperties = UserDirectoryApi.GetUserData(TestConfig.NewUser);
            }
            CurrentUser = TestConfig.NewUser;
            const string itemTitle = "Daily report template";
            var          itemsReportEmailSubject = $"Items report {CurrentTenantCode}";
            Item         item = null, custItem1 = null, custItem2 = null;
            var          app       = AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true);

            Parallel.Invoke(
                () => item = ItemApi.SearchItem(itemTitle),
                () => AddPlaceNoType(PlaceStatus.NoDevice, isAddChild: false, pageToBeOpened: 0,
                                     isCreateNewPlace: true),
                () => AddItem(ItemType.Employee),
                () => AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => AddItem(ItemType.Car),
                () => custItem1 = AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => custItem2 = AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => ItemApi.FollowItems(ItemType.CustomerProfile),
                () => ItemApi.FollowItems(ItemType.Car),
                () => ItemApi.FollowItems(ItemType.Employee)
                );
            Assert.IsNotNull(item,
                             $@"Item '{itemTitle}' not found. Is iBeacon app imported and available on tenant " +
                             $"{CurrentTenantCode}?");
            AddItemToIbeaconApp(app, "$.texts.emails.itemsFollowReportTemplate", item);

            Parallel.Invoke(
                () => _mm.InboxHousekeeping(_mm.ClientCxM),
                () => ItemApi.DeleteItem(custItem1.Id),
                () => ItemApi.SaveItem(custItem2),
                () => AddItem(ItemType.PorscheCar, isAddNew: true),
                () => AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => AddItem(ItemType.UsedCar, isAddNew: true),
                () => AddItem(ItemType.ServiceBooking, isAddNew: true)
                );

            // it's time to start checking mail box
            WaitForTimeOfDay(new TimeSpan(08, 00, 00));
            // expects a new email within 600 seconds
            var gotNewMail         = WaitForNewMail(_mm.ClientCxM, 600);

            Assert.IsTrue(gotNewMail, $"There is no new daily report found in mailbox {TestConfig.MailServerLogin}");

            var hasUserName        = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{userProperties.GivenName} {userProperties.FamilyName}");

            Assert.IsTrue(hasUserName, "Item report email has no user firstname or lastname");

            var tenantTitle        = CurrentTenant.ToString();
            var hasTenantTitle     = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                tenantTitle);

            Assert.IsTrue(hasTenantTitle, $@"Item report email has no tenant title '{tenantTitle}'");

            var custProfileContent = $"{ItemTypeCustomerProfile}: 1 new {ItemTypeCustomerProfile}, " +
                                     $"1 updated {ItemTypeCustomerProfile}, 1 deleted {ItemTypeCustomerProfile}";
            var hasCustProfileInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                custProfileContent);

            Assert.IsTrue(hasCustProfileInfo, $@"Item report email has no text: '{custProfileContent}'");

            var hasPorscheCarsAndUsedCars = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypePorscheCar}s, {ItemTypeUsedCar}s");

            Assert.IsTrue(hasPorscheCarsAndUsedCars,
                          "Item report email has no info about updated item types: " +
                          $@"'{ItemTypePorscheCar}s, {ItemTypeUsedCar}s'");

            var hasPorscheCarsInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypePorscheCar}: 1 new {ItemTypePorscheCar}");

            Assert.IsTrue(hasPorscheCarsInfo,
                          $@"Item report email has no info about followed item: '{ItemTypePorscheCar}: 1 new " +
                          $@"{ItemTypePorscheCar}'");

            var hasUsedCarsInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypeUsedCar}: 1 new {ItemTypeUsedCar}");

            Assert.IsTrue(hasUsedCarsInfo,
                          $@"Item report email has no info about followed item: '{ItemTypeUsedCar}: 1 new " +
                          $@"{ItemTypeUsedCar}'");

            var hasNoEmployeeInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                ItemTypeEmployee);

            Assert.IsTrue(hasNoEmployeeInfo,
                          $"Item report email must contain no {ItemTypeEmployee} items info");

            var hasNoServiceBookingInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                ItemTypeServiceBooking);

            Assert.IsTrue(hasNoServiceBookingInfo,
                          $"Item report email must contain no {ItemTypeServiceBooking} items info");
        }
コード例 #19
0
 public void Init()
 {
     instance = new ItemApi();
 }
コード例 #20
0
 public static void UploadTemporaryMultimediaCall()
 {
     const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
     var          api       = new ItemApi(simpleKey);
 }
コード例 #21
0
 public static void GetItemByMerchantItemIdCall()
 {
     const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
     var          api       = new ItemApi(simpleKey);
 }
コード例 #22
0
 public void Init()
 {
     instance = new ItemApi();
     ApiClient apiClient;
 }
コード例 #23
0
        public void RT08030_ItemReferenceToIbeaconApp2()
        {
            Place place1 = null, place2 = null, place3 = null;
            Item  item1 = null, item2 = null, item3 = null;

            Parallel.Invoke(
                () => place1 = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place2 = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place3 = AddPlaceIbeacon(PlaceStatus.Deleted, pageToBeOpened: 0),
                () => AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true),
                () => ItemApi.DeleteItems(ItemType.Poi, CurrentTenant)
                );
            Parallel.Invoke(
                () => item1 = AddItem(ItemType.PorscheCar, isAddNew: true),
                () => item2 = AddItem(ItemType.UsedCar, isAssignImage: true, isAddNew: true),
                () => AddItem(ItemType.EmailTemplate, isAddNew: true),
                () => item3 = AddItem(ItemType.Poi)
                );
            ItemApi.DeleteItem(item3.Id);
            TestStart();

            OpenEntityPage(place1);
            EditForm();
            MouseOver(PageFooter.AddPlaceSubMenu);
            Click(PageFooter.AddAppInPlacesButton);
            Click(AppsPage.TableCellIbeaconApp);
            ClickUntilShown(PlacesPage.AppsSectionTableRowDetailsPoiDropDown, CommonElement.DropDownInput);
            SendText(CommonElement.DropDownInput, item3.LangJsonData.EnJson.Title);
            Assert.IsTrue(IsElementNotFoundQuickly(CommonElement.DropDownOptionList),
                          $@"Apps: Deleted item '{item3.LangJsonData.EnJson.Title}' is displayed in POI field dropdown list");

            Click(PlacesPage.Title);
            Click(PlacesPage.AppsSectionTableRowDetailsPoiDetailsButton);
            Assert.IsTrue(IsElementFoundQuickly(PlacesPage.NoItemsToBeAddedDialog),
                          @"Dialog 'No items to be added' should be displayed");

            Click(PlacesPage.OkButton);
            Click(PlacesPage.AppsSectionTableRowDetailsCarDetailsButton);
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title)) &&
                          IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title)),
                          $"Items {item1.LangJsonData.EnJson.Title} and {item2.LangJsonData.EnJson.Title} should be in list");

            Click(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title));

            SubmitForm();
            OpenEntityPage(item2);
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)),
                          $"References: Field Places should contain place {place1.Title}");

            Assert.IsTrue(IsElementNotFound(ItemsPage.AssignedPlacesPlaceReadOnly),
                          "Assigned places: section should be empty");

            EditForm();
            ClickUntilShown(ItemsPage.AssignedPlacesAddButton, ItemsPage.AssignedPlacesPlaceDropDown);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(CommonElement.DropDownOption, place1.Title)),
                          $"Place {place1.Title} should not be available in dropdown");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place2.Title)),
                          $"Place {place2.Title} should be available in dropdown");

            DropDownSelect(ItemsPage.AssignedPlacesPlaceDropDown, place2.Title);

            Click(ItemsPage.PicturesSectionAddButton);
            Click(ItemsPage.PicturesSectionUploadButton);
            FileManager.Upload(TestConfig.ImageCar);
            SubmitForm();
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)) &&
                          IsElementFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place2.Title)),
                          $"References: Field Places should contain places {place1.Title} and {place2.Title}");

            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title));
            EditForm();
            Click(PlacesPage.AppsSectionTableRow1);
            Click(PlacesPage.AppsSectionTableRow1DeleteButton);
            SubmitForm();
            OpenEntityPage(item2);
            Assert.IsTrue(IsElementNotFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)),
                          $"References: Field Places should not contain place {place1.Title}");
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place3.Title)),
                          $"References: Field Places should not contain place {place3.Title}");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place2.Title)),
                          $"References: Field Places should contain place {place2.Title}");

            OpenEntityPage(item1);
            EditForm();
            ClickUntilShown(ItemsPage.AssignedPlacesAddButton, ItemsPage.AssignedPlacesPlaceDropDown);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(IsElementFound(string.Format(CommonElement.DropDownOption, place1.Title)) &&
                          IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place2.Title)),
                          $"Assigned places: Place dropdown should contain places {place1.Title} and {place2.Title}");

            DropDownSelect(ItemsPage.AssignedPlacesPlaceDropDown, place2.Title);
            SubmitForm();
            OpenEntityPage(place2);
            Assert.IsTrue(
                IsElementFound(string.Format(PlacesPage.ItemsSectionItemByTitle, item1.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item2.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item2.LangJsonData.EnJson.Title}");

            EditForm();
            MouseOver(PageFooter.AddPlaceSubMenu);
            Click(PageFooter.AddAppInPlacesButton);
            Click(AppsPage.TableRowIbeaconApp);
            ClickUntilShown(PlacesPage.AppsSectionTableRowDetailsCarDetailsButton, PlacesPage.SelectItemDialog);
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title)),
                $"Item list: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title)),
                $"Item list: Should contain item {item2.LangJsonData.EnJson.Title}");

            Click(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title));
            SubmitForm();
            Click(PageFooter.DuplicateButton);
            var title = $"Auto test {RandomNumber}";

            SendText(ItemsPage.Title, title);
            SubmitForm();
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item1.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item2.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item2.LangJsonData.EnJson.Title}");
            Click(PlacesPage.AppsSectionTableRow1);
            Assert.IsTrue(
                AreElementsContainText(PlacesPage.AppsSectionTableRowDetailsCarReadOnly, item1.LangJsonData.EnJson.Title),
                $"Apps section: Car field should contain item {item1.LangJsonData.EnJson.Title}");

            OpenEntityPage(item2);
            Assert.IsTrue(AreElementsContainText(ItemsPage.AssignedPlacesPlaceReadOnly, place2.Title) &&
                          AreElementsContainText(ItemsPage.AssignedPlacesPlaceReadOnly, title),
                          $"Assigned places: should contain both {place2.Title} and its duplicate {title}");
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place2.Title) &&
                          AreElementsContainText(ItemsPage.ReferencesSectionPlaces, title),
                          $"References: Field Places should contain both {place2.Title} and its duplicate {title}");
        }
コード例 #24
0
        public void RT08020_ItemReferenceToIbeaconApp1()
        {
            Item item1 = null, item2 = null, item3 = null;
            var  app = AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true);

            Parallel.Invoke(
                () => item1 = AddItem(ItemType.PorscheCar, isAddNew: true),
                () => item2 = AddItem(ItemType.EmailTemplate, isAddNew: true),
                () => item3 = AddItem(ItemType.EmailTemplate, isAddNew: true),
                () => ItemApi.DeleteItems(ItemType.ServiceBooking)
                );
            TestStart();

            OpenEntityPage(item2);
            Assert.IsTrue(IsElementNotFound(ItemsPage.ReferencesSectionPlaces),
                          "Reference section in item should be absent by default");

            OpenEntityPage(app);
            EditForm();
            ClickUntilShown(AppsPage.TextsButton, AppsPage.EmailsButton);
            Click(AppsPage.EmailsButton);
            Click(AppsPage.WelcomeNewCustomerDetailsButton);
            Assert.IsTrue(AreAllElementsContainText(ItemsPage.TableRowStatus, StatusActive),
                          $@"All items in 'Select item' dialog should be {StatusActive}");
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title)),
                          $@"All items in 'Select item' dialog should be {ItemTypeEmailTemplate} type");

            Click(AppsPage.CancelButton);
            ClickUntilShown(AppsPage.WelcomeNewCustomer, CommonElement.DropDownInput);
            Assert.IsTrue(IsElementFoundQuickly(AppsPage.WelcomeNewCustomerDetailsButton),
                          @"Field 'Welcome new customer' should have details button");

            SendText(CommonElement.DropDownInput, "Porsche");
            Assert.IsTrue(IsElementNotFound(CommonElement.DropDownOptionList),
                          @"Dropdown 'Welcome new customer' is not empty");

            SendText(CommonElement.DropDownInput, "Auto");
            Assert.IsTrue(IsElementFound(string.Format(CommonElement.DropDownOption, "Auto")),
                          @"Field 'Welcome new customer' should show dropdown items");

            Click(string.Format(CommonElement.DropDownOption, item2.JsonDataTitle), noScroll: true);
            Assert.IsTrue(AreElementsContainText(AppsPage.WelcomeNewCustomer, item2.JsonDataTitle),
                          $@"Field 'Welcome new customer' should contain {item2.JsonDataTitle}");

            ClickUntilShown(AppsPage.WelcomeNewCustomer, CommonElement.DropDownInput);
            SendText(CommonElement.DropDownInput, string.Empty);
            SubmitForm();
            ClickUntilShown(AppsPage.TextsButton, AppsPage.EmailsButton);
            Click(AppsPage.EmailsButton);
            Assert.IsTrue(AreElementsContainText(AppsPage.WelcomeNewCustomerReadOnly, item2.JsonDataTitle),
                          $@"Field 'Welcome new customer' should contain {item2.JsonDataTitle}");

            OpenEntityPage(item2);
            Assert.IsTrue(IsElementFound(
                              string.Format(ItemsPage.ReferencesSectionPlaceByTitle, AppTitle.Ibeacon)),
                          $"References: Apps field should contain {AppTitle.Ibeacon} app");

            EditForm();
            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, AppTitle.Ibeacon));
            Assert.IsTrue(IsPageContainsUri($"{TestConfig.AppUri}/{app.AppId}"),
                          $"User should be redirected to app {AppTitle.Ibeacon} page");

            ClickUntilShown(AppsPage.TextsButton, AppsPage.EmailsButton);
            Click(AppsPage.EmailsButton);
            Assert.IsTrue(IsElementNotFoundQuickly(AppsPage.WelcomeNewCustomerDetailsButton),
                          @"Field 'Welcome new customer' still has details button");

            EditForm();
            Click(AppsPage.ProfileReportTemplateDropDownDetailsButton);
            Assert.IsTrue(IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item2.JsonDataTitle)),
                          $@"Item {item2.JsonDataTitle} should be shown in 'Select item' dialog");

            Click(string.Format(ItemsPage.TableRowByTitle, item2.JsonDataTitle));
            Assert.IsTrue(AreElementsContainText(AppsPage.ProfileReportTemplateDropDown, item2.JsonDataTitle),
                          $"Field 'Profile report template' should contain {item2.JsonDataTitle}");

            SubmitForm();
            OpenEntityPage(item2);
            Assert.IsTrue(CountElements(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, AppTitle.Ibeacon)) == 1,
                          $"References: Apps field should contain 1 app {AppTitle.Ibeacon} record");

            Click(PageFooter.DeleteButton);
            Assert.IsTrue(IsElementFoundQuickly(ItemsPage.ItemIsReferencedDialog),
                          @"Dialog 'item is referenced' should be displayed");

            Click(ItemsPage.OkButton);
            Click(PageFooter.DuplicateButton);
            SendText(ItemsPage.Title, ItemTypeWelcomeEmailTemplate + " 2");
            SendText(ItemsPage.Key, RandomNumber);
            SubmitForm();
            Assert.IsTrue(IsElementNotFound(ItemsPage.ReferencesSectionPlaces),
                          "There should be no References section for duplicated item");

            OpenEntityPage(app);
            EditForm();
            ClickUntilShown(AppsPage.TextsButton, AppsPage.EmailsButton);
            Click(AppsPage.EmailsButton);
            Click(AppsPage.WelcomeNewCustomerDetailsButton);
            Click(ItemsPage.ClearSelectionButton);
            Assert.IsTrue(IsElementEquals(AppsPage.WelcomeNewCustomer, string.Empty),
                          @"Field 'Welcome new customer' should be empty");

            ClickUntilShown(AppsPage.ProfileReportTemplateDropDown, CommonElement.DropDownInput);
            SendText(CommonElement.DropDownInput, item3.JsonDataTitle);
            Assert.IsTrue(IsElementFound(string.Format(CommonElement.DropDownOption, item3.JsonDataTitle)),
                          @"Field 'Profile report template' should show dropdown items");

            PressKeys(Keys.Enter);
            Assert.IsTrue(AreElementsContainText(AppsPage.ProfileReportTemplateDropDown, item3.JsonDataTitle),
                          $@"Field 'Profile report template' should contain {item3.JsonDataTitle}");

            SubmitForm();
            EditForm();
            ClickUntilShown(AppsPage.TextsButton, AppsPage.EmailsButton);
            Click(AppsPage.EmailsButton);
            Click(AppsPage.WelcomeNewCustomerDetailsButton);
            PressKeys(Keys.Escape);
            Assert.IsTrue(IsElementNotFoundQuickly(AppsPage.SelectItemDialog),
                          @"'Select item' dialog should be closed on Esc button press");
            Assert.IsTrue(IsEditMode(), "App page should be in edit mode");

            Click(PageFooter.CancelButton);
            OpenEntityPage(item2);
            Assert.IsTrue(IsElementNotFound(ItemsPage.ReferencesSectionPlaces),
                          $"There should be no References section for item {item2.JsonDataTitle}");

            AppApi.DeleteApps(true, new [] { AppTitle.Ibeacon }, CurrentTenant);
            OpenEntityPage(item3);
            Assert.IsTrue(IsElementNotFound(ItemsPage.ReferencesSectionPlaces),
                          $"There should be no References section for item {item3.JsonDataTitle}");

            Click(PageFooter.DeleteButton);
            Click(ItemsPage.DeleteButton);
            Assert.IsTrue(IsPageContainsUri(TestConfig.ItemsUri),
                          $"Item {item3.JsonDataTitle} cannot be deleted");
        }