本文整理汇总了C#中Repository.Store方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Store方法的具体用法?C# Repository.Store怎么用?C# Repository.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.Store方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
const string TEST_REPO_PATH = @"c:\appzwitschern";
if (Directory.Exists(TEST_REPO_PATH)) Directory.Delete(TEST_REPO_PATH, true);
var repo = new Repository(TEST_REPO_PATH);
var va1 = new Versandauftrag() { Text = "a", Termin = new DateTime(2012, 6, 21), Id = Guid.NewGuid().ToString() };
repo.Store(va1, null);
var endOfStream = false;
var va2 = new Versandauftrag() { Text = "b", Termin = new DateTime(2012, 6, 20), Id = Guid.NewGuid().ToString() };
repo.Store(va2, null);
repo.Store(null, () => endOfStream = true);
Assert.IsTrue(endOfStream);
endOfStream = false;
var results = new List<string>();
repo.List(results.Add);
Assert.That(results.Select(fn => fn==null ? null : Path.GetFileName(fn)).ToArray(),
Is.EquivalentTo(new[] { va1.Id + ".tweet", va2.Id + ".tweet", null }));
var resultVAs = new List<Versandauftrag>();
foreach(var fn in results)
repo.Load(fn, resultVAs.Add);
Assert.That(resultVAs.Select(_ => _==null ? null : _.Text).ToArray(),
Is.EquivalentTo(new[]{"a", "b", null}));
resultVAs.ForEach(va => repo.Delete(va, () => endOfStream = true));
Assert.AreEqual(0, Directory.GetFiles(TEST_REPO_PATH).Length);
Assert.IsTrue(endOfStream);
Directory.Delete(TEST_REPO_PATH);
}
示例2: New_employee_UpdateAt_shouldbe_null
public void New_employee_UpdateAt_shouldbe_null()
{
// Arrange
var fix = new Fixture();
var repo = new Repository<Employee>();
var employee = fix.Build<Employee>()
.With(p => p.Name)
.With(p => p.StartDate)
.OmitAutoProperties()
.Create();
repo.Store(employee);
// Act
var employeeDb = repo.Get(p => p.Name == employee.Name);
// Assert
Assert.IsNotNull(employeeDb);
Assert.IsNull(employeeDb.UpdateAt);
}
示例3: New_employee_should_with_CreateAt_today
public void New_employee_should_with_CreateAt_today()
{
// Arrange
var fix = new Fixture();
var repo = new Repository<Employee>();
var employee = fix.Build<Employee>()
.With(p => p.Name)
.With(p => p.StartDate)
.OmitAutoProperties()
.Create();
repo.Store(employee);
// Act
var employeeDb = repo.Get(p => p.Name == employee.Name);
// Assert
Assert.IsNotNull(employeeDb);
Assert.IsNotNull(employeeDb.CreateAt);
Assert.AreEqual(DateTime.Now.ToShortDateString(), employeeDb.CreateAt.ToShortDateString());
}
示例4: New_employee_Status_shouldbe_WaitingConfirmation
public void New_employee_Status_shouldbe_WaitingConfirmation()
{
// Arrange
var fix = new Fixture();
using (var repo = new Repository<Employee>())
{
var employee = fix.Build<Employee>()
.With(p => p.Name)
.With(p => p.StartDate)
.OmitAutoProperties()
.Create();
repo.Store(employee);
// Act
var employeeDb = repo.Get(p => p.Name == employee.Name);
// Assert
Assert.IsNotNull(employeeDb);
Assert.AreEqual(employeeDb.Status, StatusEmployeeEnum.WaitingConfirmation);
}
}
示例5: New_employee_Id_shouldbe_generate
public void New_employee_Id_shouldbe_generate()
{
// Arrange
var fix = new Fixture();
using (var repo = new Repository<Employee>())
{
var employee = fix.Build<Employee>()
.With(p => p.Name)
.With(p => p.StartDate)
.OmitAutoProperties()
.Create();
repo.Store(employee);
// Act
var employeeDb = repo.Get(p => p.Name == employee.Name);
// Assert
Assert.IsNotNull(employeeDb);
Assert.IsTrue(employeeDb.Id > 0);
}
}
示例6: Run
public void Run()
{
using (var sut = new Repository(SERVER, TokenRepository.LoadFrom("ftp.credentials.txt"), "AppZwitschern_TweetStore"))
{
Console.WriteLine("storing...");
var versandaufträge = new[]
{
new Versandauftrag()
{Id = "1", Termin = new DateTime(2012, 3, 26, 12, 21, 0), Text = "a"},
new Versandauftrag()
{Id = "2", Termin = new DateTime(2011, 10, 27, 14, 17, 0), Text = "b"}
,
null
};
var versandt = false;
versandaufträge.ToList().ForEach(_ => sut.Store(_, () => versandt = true));
Console.WriteLine(" stored!");
Assert.IsTrue(versandt);
Console.WriteLine("listing...");
var filenames = new List<string>();
sut.List(filenames.Add);
filenames.ForEach(fn => Console.WriteLine("list {0}", fn));
Assert.AreEqual(3, filenames.Count);
Console.WriteLine("loading...");
var results = new List<Versandauftrag>();
filenames.ForEach(fn => sut.Load(fn, results.Add));
Console.WriteLine(" loaded!");
Assert.That(results.Select(_ => _ == null ? null : _.Id).ToArray(),
Is.EquivalentTo(new[] {"1", "2", null}));
Console.WriteLine("deleting...");
var deleted = false;
results.ForEach(va => sut.Delete(va, () => deleted = true));
Console.WriteLine(" deleted!");
Assert.IsTrue(deleted);
}
}