本文整理汇总了C#中Facade类的典型用法代码示例。如果您正苦于以下问题:C# Facade类的具体用法?C# Facade怎么用?C# Facade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Facade类属于命名空间,在下文中一共展示了Facade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: User_should_be_able_to_delete_an_widget_from_page
public void User_should_be_able_to_delete_an_widget_from_page()
{
var facade = default(Facade);
var profile = default(UserProfile);
var wiId = default(int);
var userSetup = default(UserSetup);
"Given a new user".Context(() =>
{
profile = MembershipHelper.CreateNewAnonUser();
facade = new Facade(new AppContext(string.Empty, profile.UserName));
userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
});
"When user adds a new page".Do(() =>
{
var widgets = facade.GetWidgetInstancesInZoneWithWidget(
facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);
wiId = widgets.First().Id;
facade.DeleteWidgetInstance(wiId);
});
"It should add a new blank page as current page".Assert(() =>
{
var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);
var widgets = facade.GetWidgetInstancesInZoneWithWidget(
facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);
Assert.Equal(0, widgets.Where(wi => wi.Id == wiId).Count());
});
}
示例2: AddToShoppingCart
public ActionResult AddToShoppingCart(int movieId, int amount)
{
MakeShoppingCart();
HttpCookie myCookie = Request.Cookies.Get(CART_NAME);
ShoppingCart cart = JsonConvert.DeserializeObject<ShoppingCart>(myCookie.Value);
if (lookInCart(cart,movieId))
{
var orderline = cart.Orderline.First(c => c.Movie.Id == movieId);
orderline.Amount += amount;
}
else
{
var mov = new Facade().GetMovieGateway().Get(movieId);
cart.Orderline.Add(new Orderline() { Amount = amount, Movie = mov });
}
myCookie.Value = JsonConvert.SerializeObject(cart);
myCookie.Expires = DateTime.Now.AddDays(PERSISTANCE_TIME); // this will make the cart persist longer.
this.HttpContext.Response.Cookies.Set(myCookie);
return RedirectToAction("Index","Home");
//this should allow you to return nothing, I imagine that this could be useful
//for JavaScript
// return null
}
示例3: User_should_be_able_change_page_title
public void User_should_be_able_change_page_title()
{
var facade = default(Facade);
var profile = default(UserProfile);
var userSetup = default(UserSetup);
var newName = Guid.NewGuid().ToString();
"Given a new user".Context(() =>
{
profile = MembershipHelper.CreateNewAnonUser();
facade = new Facade(new AppContext(string.Empty, profile.UserName));
userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
});
"When user changes title of current page".Do(() =>
{
facade.ChangeTabName(newName);
});
"It should persist and on next visit the new page title should reflect".Assert(() =>
{
var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);
Assert.Equal(newName, userTabSetup.CurrentTab.Title);
});
}
示例4: Main
static void Main()
{
Facade facade = new Facade();
facade.MethodA();
facade.MethodB();
}
示例5: Admin_user_can_add_new_widget_and_assign_roles_to_widget
public void Admin_user_can_add_new_widget_and_assign_roles_to_widget()
{
var facade = default(Facade);
var newWidget = default(Widget);
"Given an admin user".Context(() =>
{
facade = new Facade(new AppContext(string.Empty, ADMIN_USER));
});
"When user adds a new widget and assigns roles to it".Do(() =>
{
newWidget = facade.AddWidget("Test Widget",
"omaralzabir.com", string.Empty, "Test widget",
string.Empty, false, false, 0, "guest",
(int)Enumerations.WidgetType.PersonalTab);
facade.AssignWidgetRoles(newWidget.ID, new string[] { GUEST_ROLE });
});
"It should be available to the users of that role".Assert(() =>
{
var newUserProfile = MembershipHelper.CreateNewAnonUser();
facade.SetUserRoles(newUserProfile.UserName, new string[] { GUEST_ROLE });
var widgetsAvailable = facade.GetWidgetList(newUserProfile.UserName, Enumerations.WidgetType.PersonalTab);
Assert.Equal(1, widgetsAvailable.Where(w => w.ID == newWidget.ID).Count());
});
}
示例6: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
Employee uIEmployee = new Employee();
uIEmployee.EmployeeFirstName = this.FirstNameTextBox.Text;
uIEmployee.EmployeeLastName = this.LastNameTextBox.Text;
uIEmployee.Employeetype = this.EmployeeTypeTextBox.Text;
uIEmployee.EmployeePhone = this.PhoneTextBox.Text;
object Class = uIEmployee;
int ActionType = 1;
//Facade newFacade = new Facade(uIEmployee, ActionType);
Facade newFacade = new Facade(Class, ActionType);
newFacade.ProcessRequest();
if (Page.IsValid)
{
SuccessLabel.Text = "You have successfully registered on the FFR's website";
}
else
{
SuccessLabel.Text = "Failed to registers on FFR's website, please verify you have entered all necessary information.";
}
//deploy project
//CustomerManager cm = new CustomerManager();
//cm.Insert(uICustomer);
/*XmlWriterSettings xmlSetting = new XmlWriterSettings();
xmlSetting.Indent = true;
string xmlFileName = "CustomerTest.xml";
//XmlWriter xmlWriter = XmlWriter.Create("@C:, xmlSetting);
XmlWriter xmlWriter = XmlWriter..Create(xmlFileName, xmlSetting);
xmlWriter.WriteStartDocument();
xmlWriter.WriteComment("This Xml is generated when a customer registers on FFR's site");
xmlWriter.WriteStartElement("Customer");
xmlWriter.WriteElementString("ObjectType", "Customer");
xmlWriter.WriteElementString("ActionType", "1");
xmlWriter.WriteElementString("FirstName", this.FirstNameTextBox.Text);
xmlWriter.WriteElementString("LastName", this.LastNameTextBox.Text);
xmlWriter.WriteElementString("City", this.CityTextBox.Text);
xmlWriter.WriteElementString("State", this.StateTextBox.Text);
xmlWriter.WriteElementString("Street", this.StreetTextBox.Text);
xmlWriter.WriteElementString("Zip", this.StateTextBox.Text);
xmlWriter.WriteElementString("Phone", this.PhoneTextBox.Text);
xmlWriter.WriteElementString("Email", this.EmailTextBox.Text);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
Facade newFacade = new Facade(xmlWriter, xmlFileName);
newFacade.ProcessRequest();
xmlWriter.Dispose();
xmlFileName = "";*/
}
示例7: Movie_add_will_create_new_genre_test
public void Movie_add_will_create_new_genre_test()
{
Facade facade = new Facade();
Movie temp = new Movie() { Genres = new List<Genre>() { new Genre() {Name = "test" } }, Name = "test", Price = 120d, TrailerURL = "test" };
temp = facade.GetMovieRepo().Add(temp);
Assert.AreEqual(facade.GetMovieRepo().Get(temp.Id).Genres.FirstOrDefault().Name, "test");
}
示例8: Facade
static Facade()
{
Singleton = new Facade ();
Singleton.Lies = new Dictionary<Facet, HashSet<Lie>> ();
foreach (Facet f in Enum.GetValues(typeof(Facet)).Cast<Facet>()) {
Singleton.Lies[f] = new HashSet<Lie> ();
}
}
示例9: Update
public HttpResponseMessage Update(Identity id, Facade.GroupPut group)
{
return ProcessPut(() =>
{
var instance = group.ToModel();
updateGroupCommand.Execute(instance);
});
}
示例10: LoadWidgets
private void LoadWidgets()
{
using (Facade facade = new Facade(AppContext.GetContext(Context)))
{
Widgets.DataSource = facade.GetAllWidgets();
Widgets.DataBind();
}
}
示例11: GetPdfFailsIdInvoiceIdIsNotValidInteger
public void GetPdfFailsIdInvoiceIdIsNotValidInteger()
{
//Arrange
var sut = new Facade{Session = SessionMock.Object};
//Act
sut.GetPdf("not an integer");
}
示例12: SaveWidget_Clicked
protected void SaveWidget_Clicked(object sender, EventArgs e)
{
try
{
var control = LoadControl(Field_Url.Value);
}
catch (Exception x)
{
Debug.WriteLine(x.ToString());
Services.Get<ILogger>().LogException(x);
Error.Text = x.Message;
Error.Visible = true;
return;
}
using (Facade facade = new Facade(AppContext.GetContext(Context)))
{
var widgetId = int.Parse(Field_ID.Value.Trim());
if (widgetId == 0)
{
var newlyAddedWidget = facade.AddWidget(
Field_Name.Value,
Field_Url.Value,
Field_Icon.Value,
Field_Description.Value,
Field_DefaultState.Value,
Field_IsDefault.Checked,
Field_IsLocked.Checked,
int.Parse(Field_OrderNo.Value),
Field_RoleName.Value,
int.Parse(Field_WidgetType.Value));
widgetId = newlyAddedWidget.ID;
SetWidgetRoles(widgetId);
this.EditWidget(newlyAddedWidget);
}
else
{
facade.UpdateWidget(widgetId,
Field_Name.Value,
Field_Url.Value,
Field_Icon.Value,
Field_Description.Value,
Field_DefaultState.Value,
Field_IsDefault.Checked,
Field_IsLocked.Checked,
int.Parse(Field_OrderNo.Value),
Field_RoleName.Value,
int.Parse(Field_WidgetType.Value));
SetWidgetRoles(widgetId);
}
this.LoadWidgets();
EditForm.Visible = false;
}
}
示例13: Create
public HttpResponseMessage Create(Facade.SubscriptionPost subscription)
{
return ProcessPost(() =>
{
var instance = subscription.ToModel();
createCommand.Execute(instance);
return ResourceLocation.OfSubscription(instance.Id.Value);
});
}
示例14: Movie_get_by_genre_return_empty_on_no_movies_test
public void Movie_get_by_genre_return_empty_on_no_movies_test()
{
Facade facade = new Facade();
Genre genre = new Genre() { Name = "test" };
genre = facade.GetGenreRepo().Add(genre);
facade = new Facade();
Assert.AreEqual(facade.GetMovieRepo().GetMovieByGenre(genre).ToList().Count, 0);
}
示例15: Create
public HttpResponseMessage Create(Facade.GroupPost topic)
{
return ProcessPost(() =>
{
var instance = topic.ToModel();
createGroupCommand.Execute(instance);
return ResourceLocation.OfGroup(instance.Id.Value);
});
}