本文整理汇总了C#中PageModel.SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C# PageModel.SaveAs方法的具体用法?C# PageModel.SaveAs怎么用?C# PageModel.SaveAs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel.SaveAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAs_Should_Validate_New_Id_Exists
public void SaveAs_Should_Validate_New_Id_Exists()
{
dynamic data = new ExpandoObject();
data.Id = "old-id";
data.Title = "new title";
var repository = new Mock();
repository.Setup("Exists", new object[] { "new-id" }, true); // <-- it should catch this
var model = new PageModel();
model.Repository = repository;
model.SaveAs(data, "new-id");
Assert.IsTrue(model.HasError);
repository.Verify();
}
示例2: SaveAs_Should_Delete_Old_Id
public void SaveAs_Should_Delete_Old_Id()
{
dynamic data = new ExpandoObject();
data.Id = "old-id";
data.Title = "new title";
var repository = new Mock();
repository.Setup("Exists", new object[] { "new-id" }, false);
repository.Setup("Delete", new object[] { "old-id" });
repository.Setup("Save", new object[] { "new-id", It.IsAny() });
var model = new PageModel();
model.Repository = repository;
model.SaveAs(data,"new-id");
Assert.IsFalse(model.HasError); //no validation error
repository.Verify(); // all repository functions called
}