public void Gallery_Product_ApiEdit() { var urlapi = new UrlApi() { Url = "https://localhost:44397/api/v1/" }; var client = new WebClient(); var option = new Mock <IOptions <UrlApi> >(); option.Setup(c => c.Value).Returns(urlapi); var getapi = new GetProductApi(client, option.Object); var result = client.DownloadString(option.Object.Value.Url + "product/1/1"); var getAllProduct = JsonConvert.DeserializeObject <GetAllProductViewModel>(result); var product = getAllProduct.Products.LastOrDefault(); var find = new FindProductViewModel { Customer = product.Customer, SiteName = product.SiteName, SiteUrl = product.SiteUrl }; product.Customer = "Dorika"; var model = new UpdateProductViewModel { ProductBefore = find, Product = product }; result = getapi.Edit(model); Assert.Equal("Modified", result); }
public void Gallery_Product_TotalPage() { var urlapi = new UrlApi() { Url = "https://localhost:44397/api/v1/" }; var client = new WebClient(); var option = new Mock <IOptions <UrlApi> >(); option.Setup(c => c.Value).Returns(urlapi); var getapi = new GetProductApi(client, option.Object); var Result = getapi.TotalPage(new TotalPageProductViewModel { CountOnPage = 1 }); Assert.True(Result > 0); }
public void Gallery_Product_ApiGetAll() { var urlapi = new UrlApi() { Url = "https://localhost:44397/api/v1/" }; var client = new WebClient(); var option = new Mock <IOptions <UrlApi> >(); option.Setup(c => c.Value).Returns(urlapi); var getapi = new GetProductApi(client, option.Object); //var result = getapi.GetAll(new GetAllProductViewModel { CountOnPage = 1, CurrentPage = 1 }); //var resultapi = client.DownloadString(option.Object.Value.Url + $"product/1/1"); var result = getapi.GetAll(new GetAllProductViewModel { CurrentPage = 1, CountOnPage = 1 }); Assert.True(result.Products.Count > 0); }
public void Gallery_Product_Create() { var urlapi = new UrlApi() { Url = "https://localhost:44397/api/v1/" }; var client = new WebClient(); var option = new Mock <IOptions <UrlApi> >(); option.Setup(c => c.Value).Returns(urlapi); var getapi = new GetProductApi(client, option.Object); var model = new GetProductViewModel { Category = new List <string> { Faker.Developers.Designe, Faker.Developers.Developer, Faker.Developers.Host }, Customer = Faker.Lorem.Word(3), Description = Faker.Lorem.Word(50), EndDate = DateTime.Now, StartDate = DateTime.Now, Images = new List <GetImageViewModel> { new GetImageViewModel { Name = "06.jpg", Path = "/images/gallery/Test/" } }, Services = new List <string> { Faker.Lorem.Word(4), Faker.Lorem.Word(3), Faker.Lorem.Word(5) }, SiteName = Faker.Lorem.Word(3), SiteUrl = Faker.Persons.Email, Tags = new List <string> { Faker.Developers.Ecommerce, Faker.Developers.Domain, Faker.Developers.netCore } }; //var GetJsonResult = JsonConvert.SerializeObject(model); var result = getapi.Create(model); Assert.Equal("Added", result); }
public void Gallery_Product_Get() { var urlapi = new UrlApi() { Url = "https://localhost:44397/api/v1/" }; var client = new WebClient(); var option = new Mock <IOptions <UrlApi> >(); option.Setup(c => c.Value).Returns(urlapi); var getapi = new GetProductApi(client, option.Object); var result = client.DownloadString(option.Object.Value.Url + "product/1/1"); var getAllProduct = JsonConvert.DeserializeObject <GetAllProductViewModel>(result); var product = getAllProduct.Products.LastOrDefault(); var model = new FindProductViewModel { Customer = product.Customer, SiteName = product.SiteName, SiteUrl = product.SiteUrl }; //var GetJsonResult = JsonConvert.SerializeObject(model); var GetProduct = getapi.Get(model, model.Customer); helper.WriteLine(GetProduct.SiteUrl); }