public void UpdateMarketDefName() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act int marketDefinitionId = marketDefinition != null ? marketDefinition.Id : 0; string marketDefinitionName = marketDefinition != null ? marketDefinition.Name : "test"; var response = controller.updateMarketDefName(demoClientId, marketDefinitionId, marketDefinitionName); var data = context.Database.ExecuteSqlCommand("Update MarketDefinitions set Name='" + marketDefinitionName + "' Where Id=" + marketDefinitionId + ""); bool validate = false; if (data == 1) { validate = true; } //Assert Assert.IsNotNull(response); Assert.IsTrue(response); Assert.IsTrue(response == validate); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void GetMarketDefByClient() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act var response = controller.GetMarketDefByClient(demoClientId); var result = JsonConvert.DeserializeObject <MarketDefDTO[]>(response.Content.ReadAsStringAsync().Result); var marketDef = (from mar in context.MarketDefinitions where mar.ClientId == demoClientId select mar).ToList(); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Length > 0); Assert.IsTrue(result.Length == marketDef.Count); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void GetMarketDefinitionPacks() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act int marketDefinitionId = marketDefinition != null ? marketDefinition.Id : 0; var response = controller.getMarketDefinitionPacks(demoClientId, marketDefinitionId); var result = JsonConvert.DeserializeObject <Packs[]>(response.Content.ReadAsStringAsync().Result); List <Packs> marketDefinitionPacks = context.Database.SqlQuery <Packs>("Select * from vwMarketDefinitionPacks Where MarketDefinitionID=" + marketDefinitionId).ToList(); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Length > 0); Assert.IsTrue(result.Length == marketDefinitionPacks.Count); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void CheckSubcribedMarketDef() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act int marketDefinitionId = marketDefinition != null ? marketDefinition.Id : 0; var response = controller.checkSubcribedMarketDef(demoClientId, marketDefinitionId); var result = JsonConvert.DeserializeObject <string[]>(response); var subcribedMarketList = context.DeliveryMarkets.Where(p => p.MarketDefId == marketDefinitionId).ToList(); string subscriptionName = ""; if (subcribedMarketList.Count > 0) { subscriptionName = getSubscriptionName(subcribedMarketList[0].deliverables); } //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Length > 0); Assert.IsTrue(result.Contains(subscriptionName)); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void GetClientMarketDef() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act int marketDefinitionId = marketDefinition != null ? marketDefinition.Id : 0; var response = controller.getClientMarketDef(demoClientId, marketDefinitionId); var result = JsonConvert.DeserializeObject <MarketDefinition>(response.Content.ReadAsStringAsync().Result); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.ClientId == demoClientId); Assert.IsTrue(result.Id == marketDefinitionId); Assert.IsTrue(result.Name == marketDefinition.Name); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void CheckForMarketDefDuplication_ValidateForOtherMarketDef() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act var response = controller.checkForMarketDefDuplication(demoClientId, marketDefinition.Id, marketDefinition.Name); var data = context.MarketDefinitions.Where(u => u.Name.Equals(marketDefinition.Name, StringComparison.CurrentCultureIgnoreCase) && u.ClientId == demoClientId && u.Id != marketDefinition.Id).FirstOrDefault(); bool validate = false; if (data == null) { validate = true; } //Assert Assert.IsNotNull(response); Assert.IsTrue(response); Assert.IsTrue(response == validate); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void GetDynamicAvailablePackList() { try { var watch = System.Diagnostics.Stopwatch.StartNew(); //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; var query = "SELECT DISTINCT TOP 1 * from DIMProduct_Expanded"; controller.Request.Content = new StringContent(query); //controller.Request.Content = new ObjectContent<string>(query, new JsonMediaTypeFormatter(), "application/json"); //Act var response = controller.GetDynamicAvailablePackList(demoClientId); var result = JsonConvert.DeserializeObject <DataTable>(response.Content.ReadAsStringAsync().Result); watch.Stop(); //Assert Assert.IsNotNull(response); //Assert.IsTrue(result.Length > 0); var elapsedMs = watch.ElapsedMilliseconds; Assert.IsTrue(elapsedMs < 5000); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void GetMarketBases() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act int marketDefinitionId = marketDefinition != null ? marketDefinition.Id : 0; var response = controller.GetMarketBases(demoClientId, marketDefinitionId, "All Market Base"); var result = JsonConvert.DeserializeObject <DataTable>(response.Content.ReadAsStringAsync().Result); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Rows[0]["ClientName"].ToString().ToLower() == "demonstration"); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void ClientMarketBase() { try { //Arrange var controller = new API.Controllers.MarketViewController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; //Act var response = controller.ClientMarketBase(demoClientId); //Assert Assert.IsNotNull(response); Assert.IsTrue(response != "[]"); } catch (Exception exc) { Assert.Fail(exc.Message); } }