I got this error
Test
'EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events'
failed: Moq.MockVerificationException : The following setups were not
matched: IPricePackRepository pricepack =>
pricepack.Delete(It.Is(a => a.PP_EventID ==
1)) at Moq.Mock.Verify() Services\UnitTestEventSevice.cs(52,0): at
EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events()
I am wondering why on that part raising an error because they have the same logic with the eventPersistenceMock. Please help me.
namespace EM.CoreTest.Services
{
[TestFixture]
public class UnitTestEventSevice
{
[SetUp]
public void StartUp()
{
AutoMapperConfiguration.Configure();
}
[Test]
public void EventService_Return_10_Events()
{
var eventPersistenceMock = new Mock<IEventRepository>();
var pricepackPersistenceMock = new Mock<IPricePackRepository>();
var regformPersistenceMock = new Mock<IRegFormRepository>();
var attendeePersistenceMock = new Mock<IAttendeeRepository>();
var eventlists = GetEvents();
var pricepacks = GetPricepacks();
var currentevent = eventlists.ToList()[1];
eventPersistenceMock.Setup(r => r.GetAll()).Returns(eventlists);
eventPersistenceMock.Setup(u => u.Single(It.IsAny<Func<tbl_SBAem_Event, bool>>())).Returns(eventlists.Where(a => a.EventMngID == currentevent.EventMngID).Single());
eventPersistenceMock.Setup(r => r.Delete(currentevent)).Verifiable();
eventPersistenceMock.Setup(r => r.SaveChanges()).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.GetAll()).Returns(pricepacks);
pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(It.Is<tbl_SBAem_PricePackages>(a => a.PP_EventID == currentevent.EventMngID))).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.SaveChanges()).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.Delete(It.Is<tbl_SBAem_RegForm>(a => a.RF_EventID == currentevent.EventMngID))).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.SaveChanges()).Verifiable();
attendeePersistenceMock.Setup(atnd => atnd.Delete(It.Is<tbl_SBAem_Attendee>(a => a.AT_RegID == currentevent.EventMngID))).Verifiable();
attendeePersistenceMock.Setup(atnd => atnd.SaveChanges()).Verifiable();
var eventservice = new EventService(eventPersistenceMock.Object,pricepackPersistenceMock.Object,regformPersistenceMock.Object,attendeePersistenceMock.Object);
Assert.AreEqual(eventservice.EventLists().Count, 10);
Assert.AreEqual(eventservice.CustomizedQuestions(1).EventMngID, 1);
Assert.IsTrue(eventservice.DeletePage(currentevent.EventMngID));
eventPersistenceMock.Verify();
pricepackPersistenceMock.Verify();
regformPersistenceMock.Verify();
attendeePersistenceMock.Verify();
}
private IEnumerable<tbl_SBAem_PricePackages> GetPricepacks()
{
var listtblsbaemPricePackages = new List<tbl_SBAem_PricePackages>();
for (var i = 0; i < 10; i++)
{
var tblsbaemPricePackages = new tbl_SBAem_PricePackages
{
PP_AID = 1
,
PP_AccessLevel = "Access Level"
,
PP_AttendeeCount = 50
,
PP_Cost = (decimal?)34.45
,
PP_Desc = "Pricepacks Description"
,
PP_EnforceCount = 1
,
PP_EventID = i
,
PP_GID = 1
,
PP_Name = "Name"
,
PP_Tax = (decimal?)23.12
,
PricePackageID = i
};
listtblsbaemPricePackages.Add(tblsbaemPricePackages);
}
return listtblsbaemPricePackages;
}
private IEnumerable<tbl_SBAem_Event> GetEvents()
{
var listtblsbaemConfig = new List<tbl_SBAem_Event>();
for (var i = 0; i < 10; i++)
{
var tblSbAemEvent = new tbl_SBAem_Event
{
EventMngID = i
,
EM_AID = null
,
EM_Agree1Name = "Rene agree"
,
EM_Agree1Value = "Yes"
,
EM_Agree2Name = "Tessa Agree"
,
EM_Agree2Value = "Yes"
,
EM_AllowSignup = null
,
EM_BccNotify = "rene_florendo#yahoo.com.ph"
,
EM_ChargeTiming = "10:00 am"
,
EM_ContactEmail = "rene.florendo#codelean.com"
,
EM_ContactName = "Rene Florendo"
,
EM_ContactPhone = "1234567"
,
EM_CurAttendee = null
,
EM_Date = DateTime.Now
,
EM_Description = "It's me rene"
,
EM_EditStatus = null
,
EM_EmailIntro = "Hey dear I am rene"
,
EM_EmailMessage = "I love you"
,
EM_GID = null
,
EM_GuestPass = "guessPass"
,
EM_GuestUser = "rene"
,
EM_Image = "image1.png"
,
EM_Instructions = "just me"
,
EM_Link = "htpp://yahoo.com"
,
EM_Location = "makati city"
,
EM_MapLink = "http://google.com/image.png"
,
EM_MaxAttendee = null
,
EM_RegEnd = new DateTime(2012, 4, 16)
,
EM_RegStart = new DateTime(2012, 4, 16)
,
EM_ReqAddress = null
,
EM_ReqEmail = 1
,
EM_ReqOrg = 1
,
EM_ReqPhone = 1
,
EM_ReqPhone2 = 1
,
EM_ReqTitle = 1
,
EM_ShowShip = 1
,
EM_SkipAttendee = 1
,
EM_Time = "10:00 am"
,
EM_Type = "Type A"
,
EM_isTemplate = 1
,
EM_name = "Name me"
,
EM_opt1Name = "optName1"
,
EM_opt1Values = "optValues1"
,
EM_opt2Name = "optName2"
,
EM_opt2Values = "optValues2"
,
EM_opt3Name = "optName3"
,
EM_opt3Values = "optValues3"
,
EM_opt4Name = "optName4"
,
EM_opt4Values = "optValues4"
,
EM_opt5Name = "optName5"
,
EM_opt5Values = "optValues5"
,
EM_opt6Name = "optName6"
,
EM_opt6Values = "optValues6"
,
EM_reqAgree1 = null
,
EM_reqAgree2 = null
,
EM_reqOpt1 = 1
,
EM_reqOpt2 = 1
,
EM_reqOpt3 = 1
,
EM_reqOpt4 = 1
,
EM_reqOpt5 = 1
,
EM_reqOpt6 = 1
};
listtblsbaemConfig.Add(tblSbAemEvent);
}
return listtblsbaemConfig;
}
}
}
Sorry it's been a while and you probably have got the issue resolved for thousands of times.
But I met this problem today too and I've got some idea about the error.
"The following setups were not matched" means you have a mock setup, but never called.
It means you suppose
pricepack.Delete(a)
should be called. But in reality it is never called.
If you know why this is not called and you think it's a correct behaviour, just delete the setup. Otherwise you might need to investigate why this is not called.
Change the statement pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(It.Is<tbl_SBAem_PricePackages>(a => a.PP_EventID == currentevent.EventMngID))).Verifiable(); to
pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(It.IsAny<Func<tbl_SBAem_PricePackages, bool>>())).Verifiable();
public void EventService_Return_10_Events()
{
var eventPersistenceMock = new Mock<IEventRepository>();
var pricepackPersistenceMock = new Mock<IPricePackRepository>();
var regformPersistenceMock = new Mock<IRegFormRepository>();
var attendeePersistenceMock = new Mock<IAttendeeRepository>();
var eventlists = GetEvents();
var pricepacks = GetPricepacks();
var currentevent = eventlists.ToList()[1];
eventPersistenceMock.Setup(r => r.GetAll()).Returns(eventlists);
eventPersistenceMock.Setup(u => u.Single(It.IsAny<Func<tbl_SBAem_Event, bool>>())).Returns(eventlists.Where(a => a.EventMngID == currentevent.EventMngID).Single());
eventPersistenceMock.Setup(r => r.Delete(currentevent)).Verifiable();
eventPersistenceMock.Setup(r => r.SaveChanges()).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.GetAll()).Returns(pricepacks);
pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(It.IsAny<Func<tbl_SBAem_PricePackages, bool>>())).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.SaveChanges()).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.Delete(It.IsAny<Func<tbl_SBAem_RegForm,bool>>())).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.SaveChanges()).Verifiable();
attendeePersistenceMock.Setup(atnd => atnd.Delete(It.IsAny<Func<tbl_SBAem_Attendee,bool>>())).Verifiable();
attendeePersistenceMock.Setup(atnd => atnd.SaveChanges()).Verifiable();
var eventservice = new EventService(eventPersistenceMock.Object,pricepackPersistenceMock.Object,regformPersistenceMock.Object,attendeePersistenceMock.Object);
Assert.AreEqual(eventservice.EventLists().Count, 10);
Assert.AreEqual(eventservice.CustomizedQuestions(1).EventMngID, 1);
Assert.IsTrue(eventservice.DeletePage(currentevent.EventMngID));
eventPersistenceMock.Verify();
pricepackPersistenceMock.Verify();
regformPersistenceMock.Verify();
attendeePersistenceMock.Verify();
}
Related
I have written a test for edit model of a class in EF core.
public async Task<Expense> EditExpense(Expense model)
{
var expense = _dataRepository.Where<Expense>(x => x.Id == model.Id).ToList();
if(expense != null)
{
expense.ForEach(x =>
{
x.Name = model.Name;
x.AddedOn = model.AddedOn;
x.Amount = model.Amount;
x.Type = model.Type;
x.SplitOption = model.SplitOption;
x.Notes = model.Notes;
x.IsGroupExpense = model.IsGroupExpense;
});
return expense.FirstOrDefault();
}
else
{
return null;
}
}
I want to test this method using xUnit and Moq and I have also written a method for it as below.
[Fact]
public async void UnitTest_IsExpenseEdited_ReturnsTrue()
{
var expenseCurrent = new Expense()
{
Id = 5,
Name = "Test Expense",
Amount = 1500,
AddedBy = "44db32c3-ad6a-4d68-a683-862be363f59c",
AddedOn = DateTime.Now,
Notes = "",
IsDeleted = false,
IsGroupExpense = false,
SplitOption = 1,
Type = 0
};
var expenseList = (new List<Expense>{ expenseCurrent });
var expenseAfterEdit = new Expense()
{
Id = 5,
Name = "Test Expense Edited",
Amount = 2000,
AddedBy = "44db32c3-ad6a-4d68-a683-862be363f59c",
AddedOn = DateTime.Now,
Notes = "Edited !!!",
IsDeleted = false,
IsGroupExpense = true,
SplitOption = 2,
Type = 0
};
_dataRepositoryMock.Setup(x => x.Where<Expense>(a => a.Id == expenseCurrent.Id)).Returns(expenseList as IQueryable<Expense>);
var expenseEdited = await _exepenseRepository.EditExpense(expenseAfterEdit);
Assert.Equal(expenseEdited, expenseAfterEdit);
}
But here, the Where method is returning null
public async Task<Expense> EditExpense(Expense model)
{
var expense = _dataRepository.Where<Expense>(x => x.Id == model.Id).ToList(); in repository
}
I am getting var expense null in above code.
Please suggest what should I include in the code to get the value in above var expense?
To test this method, I want to create a fake data which is going to be updated. Please suggest how this thing needs to be written properly?
I need that at the time the ValueChanged event of the LargeDataComboBox is called (when I click on a row in the drop-down list) a Popup Window is displayed.
_searchPanel.cshtml
#Html.DevExpress().ComboBox(
settings =>
{
settings.Name = "comboBoxSearchPanel";
settings.Height = 30;
settings.SelectedIndex = 0;
settings.Properties.DropDownStyle = DropDownStyle.DropDown;
settings.CallbackRouteValues = new { Controller = "SearchPanel", Action = "SearchPanel" };
settings.Properties.CallbackPageSize = 30;
settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
settings.Properties.FilterMinLength = 2;
settings.Properties.ClearButton.DisplayMode = ClearButtonDisplayMode.OnHover;
settings.Properties.ValueField = "id_usuario";
settings.Properties.ValueType = typeof(string);
settings.Properties.TextFormatString = "{0} {1}";
settings.Properties.Columns.Add(column =>
{
column.FieldName = "iduser";
column.Caption = "User";
});
settings.Properties.Columns.Add(column =>
{
column.FieldName = "fullname";
column.Caption = "FUllName";
column.Width = 175;
});
settings.Properties.ClientSideEvents.ValueChanged = "function(s, e) { OnValueChangeSearchPanel(s, e)}";
}
).BindList(Model).GetHtml()
function where the ValueChanged event is called
function OnValueChangeSearchPanel(s, e) {
var x = s.GetSelectedItem().text.split(" ");
console.log(x[0]);
//I need to replace the alert with a popup
alert(x[0]);
}
_popupWindow.cshtml
#Html.DevExpress().PopupControl(settings =>
{
settings.Name = "popupUser";
settings.AllowDragging = true;
settings.ShowOnPageLoad = true;
settings.CloseAction = CloseAction.CloseButton;
settings.HeaderText = "User";
settings.SetContent(() =>
{
ViewContext.Writer.Write(
"<h1>" + "Welcome" + "</h1>"
);
});
Diagram of how it should work
The code below does the trick
function OnValueChangeSearchPanel(s, e) {
var x = s.GetSelectedItem().text.split(" ");
popupUser.Show();
}
Your Helper should look like this (complete code here)
#Html.DevExpress().PopupControl(settings =>
{
settings.Name = "popupUser";
settings.AllowDragging = true;
settings.ShowOnPageLoad = true;
settings.EnableClientSideAPI = true;
settings.CloseAction = CloseAction.CloseButton;
settings.PopupAction = PopupAction.None;
settings.HeaderText = "User";
settings.SetContent(() =>
{
ViewContext.Writer.Write(
"<h1>" + "Welcome" + "</h1>"
);
});
So my problem is that I've got to mock two things. One is a method that finds a person and the other is a list of those people over which it iterates. However it doesn't get both setups but only 1. I've tried putting them in different orders and each time only the top 1 works.
here's my code:
Person test = new Person()
{
City = "Eindhoven Area, Netherlands.",
userid = 1,
ID = 1,
Email = "fraylight#gmail.com",
ExtraInfo = "blabla",
HobbyProjectICTRelated = "a",
Hobbys = "",
LearntSkillsAndLevelOfSkills = "Java:7, C#:4, Software Documentation:4, Software Development:4, HTML:2, CSS:2, jQuery:1",
Name = "Marijn van Donkelaar",
PhoneNr = "0612345678",
ProfileImage = "/Images/hollemar.jpg",
SkillsToLearn = "ASP.net:2, JAVA:3",
Stand = "",
Summary = "",
YearsOfWorkExperience = 6,
PeopleManagerApproved = true,
PeopleManager = "Richard"
};
Person test1 = new Person()
{
City = "Eindhoven Area, Netherlands.",
userid = 2,
ID = 2,
Email = "fraylight#gmail.com",
ExtraInfo = "",
HobbyProjectICTRelated = "a",
Hobbys = "zwemmen",
LearntSkillsAndLevelOfSkills = "Java:8, C#:4, Software Documentation:4, Software Development:4, HTML:2, CSS:2, jQuery:1",
Name = "Richard Holleman",
PhoneNr = "",
ProfileImage = "/Images/hollemar.jpg",
SkillsToLearn = "ASP.net:2, JAVA:2",
Stand = "",
Summary = "",
YearsOfWorkExperience = 16,
PeopleManagerApproved = true,
PeopleManager = "Richard"
};
Person test2 = new Person()
{
City = "Eindhoven Area, Netherlands.",
userid = 3,
ID = 3,
Email = "fraylight#gmail.com",
ExtraInfo = "",
HobbyProjectICTRelated = "",
Hobbys = "zwemmen",
LearntSkillsAndLevelOfSkills = "C#:4, SQL:4, PLSQL:4, HTML:2, CSS:2, jQuery:1",
Name = "Jasmine Test",
PhoneNr = "0612345678",
ProfileImage = "/Images/hollemar.jpg",
SkillsToLearn = "ASP.net:2, JAVA:1",
Stand = "",
Summary = "",
YearsOfWorkExperience = 11,
PeopleManagerApproved = true,
PeopleManager = "Richard"
};
var data = new List<Person> { test, test1, test2 }.AsQueryable();
var dbSetMock = new Mock<IDbSet<Person>>();
dbSetMock.Setup(m => m.Provider).Returns(data.Provider);
dbSetMock.Setup(m => m.Expression).Returns(data.Expression);
dbSetMock.Setup(m => m.ElementType).Returns(data.ElementType);
dbSetMock.Setup(m => m.GetEnumerator()).Returns(() => data.GetEnumerator());
var mockContext = new Mock<PersonDBContext>();
mockContext.Setup(x => x.Persons).Returns(dbSetMock.Object);
mockContext.Setup(x => x.Persons.Find(1)).Returns(test);
var service = new PersonController(mockContext.Object);
var controllerContext = new Mock<ControllerContext>();
controllerContext.Setup(t => t.HttpContext.Session["loggedinuser"]).Returns(10);
service.ControllerContext = controllerContext.Object;
ViewResult detailspageresultcorrect = (ViewResult) service.Details(10);
Person resultpersoncorrect = (Person) detailspageresultcorrect.Model;
Assert.IsTrue(resultpersoncorrect.Name.Equals(test.Name));
The part where it goes wrong is on the line of: var mockContext = new Mock();
You should be able to mock the Find method directed on the IDbSet instead of going via the Persons property.
So your setups would look like the following:
var dbSetMock = new Mock<IDbSet<Person>>();
dbSetMock.Setup(m => m.Provider).Returns(data.Provider);
dbSetMock.Setup(m => m.Expression).Returns(data.Expression);
dbSetMock.Setup(m => m.ElementType).Returns(data.ElementType);
dbSetMock.Setup(m => m.GetEnumerator()).Returns(() => data.GetEnumerator());
dbSetMock.Setup(m => m.Find(1)).Returns(test);
var mockContext = new Mock<PersonDBContext>();
mockContext.Setup(x => x.Persons).Returns(dbSetMock.Object);
I'm using MvcxGridView to bind a DataTable model and I have a problem with a DataColumn with datatype System.Byte[].
When I view data, gridview does not show a value and only displays System.Byte[]. I want the GridView to display a picture in that column.
When I save data, I get this message:
Invalid cast from 'System.String' to 'System.Byte[]'
How can I solve these problems?
Here is my code in view:
#using System.Data;
#model TestPA6MVC.Models.EntityModelForViewDataSettingGrid
#functions{
MVCxGridViewCommandColumn CreateCommandColumn(string AllowEdit,string AllowAdd)
{
MVCxGridViewCommandColumn column = new MVCxGridViewCommandColumn();
column.Visible = true;
column.NewButton.Visible = (AllowAdd.ToLower()=="true")?true:false;
column.DeleteButton.Visible = (AllowEdit.ToLower() == "true") ? true : false; ;
//column.EditButton.Visible = true;
return column;
}
}
#{
var grid = Html.DevExpress().GridView(
settings => {
settings.Name = "gvEditing";
settings.CallbackRouteValues = new {
Controller = "Home", Action = "GridViewPartial",
ViewName = Model.ViewName,
PrimaryKeyCollection = Model.PrimaryKeyCollection,
TableEditorList = Model.TableEditorList,
ColumnComboBoxCollection = Model.ColumnComboBoxCollection,
ColumnReadOnlyCollection = Model.ColumnReadOnlyCollection,
ColumnHideCollection = Model.ColumnHideCollection,
ParamNameCollection = Model.ParamNameCollection,
DataForParamCollection = Model.DataForParamCollection,
ParamTypeCollection = Model.ParamTypeCollection,
AllowAdd = Model.AllowAdd,
AllowEdit = Model.AllowEdit
};
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Home", Action = "GridViewPartialAddNew", ViewName = Model.ViewName };
settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Home", Action = "GridViewPartialUpdate", ViewName = Model.ViewName };
settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "GridViewPartialDelete", ViewName = Model.ViewName };
settings.SettingsEditing.BatchUpdateRouteValues = new {
Controller = "Home", Action = "BatchEditingUpdateModel",
ViewName = Model.ViewName,
PrimaryKeyCollection = Model.PrimaryKeyCollection,
TableEditorList = Model.TableEditorList,
ColumnComboBoxCollection = Model.ColumnComboBoxCollection,
ColumnReadOnlyCollection = Model.ColumnReadOnlyCollection,
ColumnHideCollection = Model.ColumnHideCollection,
ParamNameCollection = Model.ParamNameCollection,
DataForParamCollection = Model.DataForParamCollection,
ParamTypeCollection = Model.ParamTypeCollection,
AllowAdd = Model.AllowAdd,
AllowEdit = Model.AllowEdit
};
if (Model.AllowEdit.ToLower() == "true")
{
settings.SettingsEditing.Mode = GridViewEditingMode.Batch;//Kieu view chinh sua
}
else { settings.SettingsEditing.Mode = GridViewEditingMode.PopupEditForm; }
settings.SettingsBehavior.ConfirmDelete = true;//Cho phep hien thi thong bao xac nhan
settings.SettingsBehavior.ColumnResizeMode = ColumnResizeMode.Control;//Cho phep chinh sua do rong cot
settings.Width = 800;//Chieu rong cua gridview
settings.Settings.HorizontalScrollBarMode = ScrollBarMode.Auto;
settings.SettingsPager.Mode = GridViewPagerMode.ShowPager;
settings.SettingsPager.PageSize = 50;
settings.Settings.VerticalScrollableHeight = 300;
settings.Settings.VerticalScrollBarMode = ScrollBarMode.Auto;
settings.SettingsPager.Visible = true;
settings.Settings.ShowGroupPanel = true;
settings.Settings.ShowFilterRow = true;
settings.Settings.ShowHeaderFilterButton = true;//Hien thi bo loc cho column
//Tao cot gia de tranh tinh trang hien thi lai cac Column an khi Callback
MVCxGridViewColumn fakeco = new MVCxGridViewColumn();
fakeco.Visible = false;
fakeco.Width = 0;
fakeco.EditFormSettings.Visible = DefaultBoolean.False;
settings.Columns.Add(fakeco);
settings.SettingsBehavior.AllowSelectByRowClick = true;
settings.DataBound = (sender, e) =>
{
//Build Column Tool Automatic
((MVCxGridView)sender).Columns.Insert(0, CreateCommandColumn(Model.AllowEdit,Model.AllowAdd));
//Add custom Column
foreach (var child in Model.ModelForDisplayColumnList)
{
MVCxGridViewColumn dc = new MVCxGridViewColumn();
dc.Caption = child.Caption;
dc.FieldName = child.ColumnName;
if(child.IsHidden)//Neu de an hoan toan se khong lay duoc du lieu da chinh sua
{ dc.Width = 0; }
//dc.Visible = !child.IsHidden;
dc.ReadOnly = child.IsReadOnly;
switch (child.DataType)
{
case "datetime":
dc.ColumnType = MVCxGridViewColumnType.DateEdit;
var DateEditProperties = dc.PropertiesEdit as DateEditProperties;
DateEditProperties.DisplayFormatString = "dd/MM/yyyy hh:mm tt";
//Cho phep chinh ngay, gio
DateEditProperties.UseMaskBehavior = true;
//Dinh dang hien thi khi chinh sua
DateEditProperties.EditFormat = EditFormat.Custom;
DateEditProperties.EditFormatString = "dd/MM/yyyy hh:mm tt";
DateEditProperties.TimeSectionProperties.Visible = true;//Hien khung chinh gio
break;
case "combobox":
dc.ColumnType = MVCxGridViewColumnType.ComboBox;
var DropDownEditProperties = dc.PropertiesEdit as ComboBoxProperties;
DropDownEditProperties.DataSource = child.DataSourceForComboBoxColumn;
DropDownEditProperties.ValueField = child.DataSourceForComboBoxColumn.Columns[0].ColumnName;
DropDownEditProperties.TextFormatString = "{0}";
foreach (DataColumn childcolumn in child.DataSourceForComboBoxColumn.Columns)
{
DropDownEditProperties.Columns.Add(childcolumn.ColumnName, childcolumn.ColumnName);
}
break;
case "boolean":
case "bit":
dc.ColumnType = MVCxGridViewColumnType.CheckBox;
break;
case "byte[]":
dc.ColumnType = MVCxGridViewColumnType.BinaryImage;
//var ImageEditProperties = dc.PropertiesEdit as BinaryImageEditProperties;
//ImageEditProperties.ImageWidth = 50;
//ImageEditProperties.ImageHeight = 50;
break;
//case "string":
// dc.ColumnType = MVCxGridViewColumnType.ComboBox;
// var ComboBoxEditProperties = dc.PropertiesEdit as ComboBoxProperties;
// ComboBoxEditProperties.DataSource = ModelForDisplayColumnList;
// ComboBoxEditProperties.TextField = "DataType";
// ComboBoxEditProperties.ValueField = "Caption";
// break;
}
((MVCxGridView)sender).Columns.Add(dc);
}
};
settings.KeyFieldName = Model.PrimaryKeyCollection;
});
if (ViewData["EditError"] != null){
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
#grid.Bind(Model.DataSourceForGrid).GetHtml()
I have scraped following page my problem is that I want to redirect my code to desired page . I get the page but its not fully loaded contain many missing information why is that?
here is the code
include("admin/LIB_http.php");
include("admin/LIB_parse.php");
include("admin/LIB_resolve_addresses.php");
include("admin/LIB_http_codes.php");
include("admin/database.php");
$action = "http://domestic-air-tickets.expedia.co.in/flights/initiate-booking";
$method="GET"; // GET method
$ref = "http://domestic-air-tickets.expedia.co.in/flights/results?from=DEL&to=HYD&depart_date=25/08/2012&adults=2&childs=0&infants=0&dep_time=0&class=Economy&airline=&carrier=&x=57&y=16&flexi_search=no ";
// Referer variable
$data_array['rnd_one'] = "O";
$data_array['from'] = "DEL";
$data_array['to'] = "HYD";
$data_array['depart_date'] = "25/08/2012";
$data_array['adults'] = "2";
$data_array['childs'] = "0";
$data_array['dep_time'] = "0";
$data_array['class'] = "Economy";
$data_array['airline'] ="";
$data_array['carrier'] = "";
$data_array['timestamp'] = "1345783916448";
$data_array['companyid'] = "110342";
$data_array['source'] = "WL";
$data_array['BIZ_ACTION_MODE'] = "VIEW_ORDER_CAPTURE";
$data_array['topLevelRateRules'] = '{"cc":{"df":{"pg":{"f":250.0}}},"dc":{"df":{"pg":{"f":250.0}}},"nb":{"df":{"pg":{"f":250.0}}},"kc":{"df":{"pg":{"f":250.0}}},"ca":{"df":{"pg":{"f":250.0}}},"tax":{"CC":0.0, "DC":0.0, "NB":0.0, "KC":0.0, "CA":0.0}}';
$data_array['emiJson'] = "{}";
$data_array['out_no_legs'] = "1";
$data_array['out_base_price'] = "8860";
$data_array['out_adult_base'] = "8860";
$data_array['out_taxes'] = "7678";
$data_array['out_disc'] = "0";
$data_array['out_price'] = "16538";
$data_array['out_fare_key'] = "supp_INDIGO|si-90efea02-d16b-4cec-808a-3d79792ea2b2|fk_6E_311_1345859400000_E0DELHYD_true_";
$data_array['out_leg_aircode_1'] = "6E";
$data_array['out_leg_from_1'] = "DEL";
$data_array['out_leg_fromCityName_1'] = "New Delhi";
$data_array['out_leg_fromAirportName_1'] = "Indira Gandhi Airport";
$data_array['out_leg_to_1'] = "HYD";
$data_array['out_leg_toCityName_1'] = "Hyderabad";
$data_array['out_leg_toAirportName_1'] = "Rajiv Gandhi International";
$data_array['out_leg_via_1'] = "n";
$data_array['out_leg_departs_date_1'] = "25/08/2012";
$data_array['out_leg_flt_num_1'] = "311";
$data_array['out_leg_arrives_date_1'] = "25/08/2012";
$data_array['out_leg_fare_basis_1'] = "E0DELHYD";
$data_array['out_leg_fare_class_1'] = "supp_INDIGO|si-90efea02-d16b-4cec-808a-3d79792ea2b2|";
$data_array['out_leg_cabin_type_1'] = "E";
$data_array['out_leg_refundable_1'] = "R";
$data_array['out_leg_oa_1'] = "";
$data_array['out_leg_arrives_1'] = "09:20";
$data_array['out_leg_departs_1'] = "07:20";
$data_array['out_leg_stops_1'] = "0";
$data_array['out_leg_departure_terminal_1'] = "Terminal 1D";
$data_array['ts'] = "10135741";
$data_array['fromCityName'] = "New Delhi";
$data_array['toCityName'] = "Hyderabad";
$response = http($target=$action, $ref, $method, $data_array, EXCL_HEAD);
print_r($response);
I can't upload images other wise u can see how page is different from original site page
I Solved it by var_dump the $response and then explode to get required URL